From d7e93736e50a7035d5fc8d19de837b632225f130 Mon Sep 17 00:00:00 2001 From: houwei Date: Tue, 5 Nov 2024 14:56:57 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=A3=8E=E6=9C=BA?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=89=B9=E9=87=8F=E6=93=8D=E6=8E=A7api?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=9B=E7=94=B1=E5=89=8D=E7=AB=AF=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E5=A4=9A=E4=B8=AA=E9=A3=8E=E6=9C=BA=E5=85=A8=E6=8E=A7?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../page/controller/WindTurbinesPageController.java | 11 ----------- .../page/service/WindTurbinesPageService.java | 12 ------------ 2 files changed, 23 deletions(-) diff --git a/das/src/main/java/com/das/modules/page/controller/WindTurbinesPageController.java b/das/src/main/java/com/das/modules/page/controller/WindTurbinesPageController.java index 79d079fc..6f5bf445 100644 --- a/das/src/main/java/com/das/modules/page/controller/WindTurbinesPageController.java +++ b/das/src/main/java/com/das/modules/page/controller/WindTurbinesPageController.java @@ -42,15 +42,4 @@ public class WindTurbinesPageController { List windTurbinesPageVos = windTurbinesPageService.queryAllWindTurbinesPages(); return R.success(windTurbinesPageVos); } - - /** - * - * @param controlList 遥控List - * @return 成功或者失败 - */ - @PostMapping ("/windTurbinesControl") - public R windTurbinesControl(HttpServletRequest request ,@RequestBody List controlList){ - windTurbinesPageService.windTurbinesControl(request,controlList); - return R.success(); - } } diff --git a/das/src/main/java/com/das/modules/page/service/WindTurbinesPageService.java b/das/src/main/java/com/das/modules/page/service/WindTurbinesPageService.java index c5ecb6c6..0e617cc7 100644 --- a/das/src/main/java/com/das/modules/page/service/WindTurbinesPageService.java +++ b/das/src/main/java/com/das/modules/page/service/WindTurbinesPageService.java @@ -120,16 +120,4 @@ public class WindTurbinesPageService { log.debug(stopWatch.prettyPrint(TimeUnit.SECONDS)); return windTurbinesPageVos; } - - public void windTurbinesControl(HttpServletRequest request,List controlList) { - for (CommandInfoDto item : controlList) { - try { - optService.executeOperation(request,item); - } catch (Exception e) { - log.error("下控失败", e); - throw new ServiceException("下控失败" + e); - } - - } - } } From 49f086bc192ce4a1e40cf7dfa7930bfadcda7843 Mon Sep 17 00:00:00 2001 From: huguanghan Date: Tue, 5 Nov 2024 15:01:15 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20=E7=A1=AE=E8=AE=A4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/event/controller/EventController.java | 4 ++-- .../com/das/modules/event/service/EventService.java | 2 +- .../modules/event/service/impl/EventServiceImpl.java | 12 +++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/das/src/main/java/com/das/modules/event/controller/EventController.java b/das/src/main/java/com/das/modules/event/controller/EventController.java index 2f1345e4..e19af6d0 100644 --- a/das/src/main/java/com/das/modules/event/controller/EventController.java +++ b/das/src/main/java/com/das/modules/event/controller/EventController.java @@ -46,8 +46,8 @@ public class EventController { * @param deviceEventInfo 确认信息 */ @PostMapping("/confirm") - public R confirmEvent(@RequestBody DeviceEventInfo deviceEventInfo){ - eventService.confirmEvent(deviceEventInfo); + public R confirmEvent(@RequestBody List deviceEventInfoList){ + eventService.confirmEvent(deviceEventInfoList); return R.success(); } } diff --git a/das/src/main/java/com/das/modules/event/service/EventService.java b/das/src/main/java/com/das/modules/event/service/EventService.java index 8185cc87..ee777d12 100644 --- a/das/src/main/java/com/das/modules/event/service/EventService.java +++ b/das/src/main/java/com/das/modules/event/service/EventService.java @@ -9,5 +9,5 @@ import java.util.List; public interface EventService { List queryEvent(EventQueryParam param); - void confirmEvent(DeviceEventInfo deviceEventInfo); + void confirmEvent(List deviceEventInfoList); } diff --git a/das/src/main/java/com/das/modules/event/service/impl/EventServiceImpl.java b/das/src/main/java/com/das/modules/event/service/impl/EventServiceImpl.java index fcb10d01..04da4c80 100644 --- a/das/src/main/java/com/das/modules/event/service/impl/EventServiceImpl.java +++ b/das/src/main/java/com/das/modules/event/service/impl/EventServiceImpl.java @@ -31,11 +31,13 @@ public class EventServiceImpl implements EventService { } @Override - public void confirmEvent(DeviceEventInfo deviceEventInfo) { + public void confirmEvent(List deviceEventInfoList) { Long confirmTime = System.currentTimeMillis(); - deviceEventInfo.setConfirmTime(confirmTime); - SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY); - deviceEventInfo.setConfirmAccount(sysUserVo.getAccount()); - tdEngineService.confirmEvent(deviceEventInfo); + for (DeviceEventInfo deviceEventInfo : deviceEventInfoList){ + deviceEventInfo.setConfirmTime(confirmTime); + SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY); + deviceEventInfo.setConfirmAccount(sysUserVo.getAccount()); + tdEngineService.confirmEvent(deviceEventInfo); + } } } From 60495b1b9c222238d3abf7b055a7c1d77b8fba4e Mon Sep 17 00:00:00 2001 From: houwei Date: Tue, 5 Nov 2024 16:30:49 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E9=A3=8E=E6=9C=BA=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WindTurbinesPageController.java | 3 - .../page/service/WindTurbinesPageService.java | 119 +---------------- .../impl/WindTurbinesPageServiceImpl.java | 122 ++++++++++++++++++ 3 files changed, 125 insertions(+), 119 deletions(-) create mode 100644 das/src/main/java/com/das/modules/page/service/impl/WindTurbinesPageServiceImpl.java diff --git a/das/src/main/java/com/das/modules/page/controller/WindTurbinesPageController.java b/das/src/main/java/com/das/modules/page/controller/WindTurbinesPageController.java index 6f5bf445..6c11be54 100644 --- a/das/src/main/java/com/das/modules/page/controller/WindTurbinesPageController.java +++ b/das/src/main/java/com/das/modules/page/controller/WindTurbinesPageController.java @@ -1,11 +1,8 @@ package com.das.modules.page.controller; import com.das.common.result.R; -import com.das.modules.node.domain.dto.DeviceCommandDto; -import com.das.modules.operation.domain.dto.CommandInfoDto; import com.das.modules.page.domian.WindTurbinesPageVo; import com.das.modules.page.service.WindTurbinesPageService; -import jakarta.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; diff --git a/das/src/main/java/com/das/modules/page/service/WindTurbinesPageService.java b/das/src/main/java/com/das/modules/page/service/WindTurbinesPageService.java index 0e617cc7..3a84462b 100644 --- a/das/src/main/java/com/das/modules/page/service/WindTurbinesPageService.java +++ b/das/src/main/java/com/das/modules/page/service/WindTurbinesPageService.java @@ -1,123 +1,10 @@ package com.das.modules.page.service; -import com.das.common.constant.EquipmentTypeIds; -import com.das.common.exceptions.ServiceException; -import com.das.modules.data.domain.SnapshotValueQueryParam; -import com.das.modules.data.service.impl.DataServiceImpl; -import com.das.modules.equipment.domain.dto.SysEquipmentDto; -import com.das.modules.equipment.domain.vo.SysEquipmentVo; -import com.das.modules.equipment.mapper.SysEquipmentMapper; -import com.das.modules.node.domain.dto.DeviceCommandDto; -import com.das.modules.operation.domain.dto.CommandInfoDto; -import com.das.modules.operation.service.OperationService; import com.das.modules.page.domian.WindTurbinesPageVo; -import jakarta.servlet.http.HttpServletRequest; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StopWatch; -import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -@Transactional(rollbackFor = Exception.class) -@Service -@Slf4j -public class WindTurbinesPageService { - - @Autowired - SysEquipmentMapper sysEquipmentMapper; - - @Autowired - private DataServiceImpl dataServiceImpl; - - @Autowired - OperationService optService; - - /** - * 获取风机机组所属线路列表 - * - * @return 返回字符串数组 - */ - public List queryBelongLines() { - return sysEquipmentMapper.queryBelongLines(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG); - } - - - /** - * 获取风机页面数据 - * - * @return 返回风机页面数据 - */ - public List queryAllWindTurbinesPages() { - StopWatch stopWatch = new StopWatch(); - stopWatch.start("获取风机页面数据"); - SysEquipmentDto sysEquipmentDto = new SysEquipmentDto(); - sysEquipmentDto.setObjectType(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG); - List sysEquipmentVos = sysEquipmentMapper.queryEquipmentListInPage(sysEquipmentDto); - //风机返回数据列表 - List windTurbinesPageVos = new ArrayList<>(); - List paramList = new ArrayList<>(); - //构建需要查询的物模型属性 - List attributesList = new ArrayList<>(); - //风速 - attributesList.add("iwindspeed"); - //风机状态 - attributesList.add("iturbineoperationmode"); - //有功功率(MW) - attributesList.add("igenpower"); - //日发电量(kwh) - attributesList.add("ikwhthisday"); - //总发电量(万kwh) - attributesList.add("ikwhoverall"); - //机舱角度 - attributesList.add("ivanedirection"); - //叶轮转速(rmp) - attributesList.add("irotorspeed"); - //发电机转速(rmp) - attributesList.add("igenspeed"); - //机舱温度(℃) - attributesList.add("itempnacelle_1sec"); - //主油路压力(kpa) - attributesList.add("ihydrpress"); - //变桨角度ipitchangle1,ipitchangle2,ipitchangle3(取最小值) - attributesList.add("ipitchangle1"); - attributesList.add("ipitchangle2"); - attributesList.add("ipitchangle3"); - //解缆状态 - attributesList.add("iyplevel"); - //电网故障停机 - attributesList.add("gridlostdetected"); - //是否锁定 - attributesList.add("Locked"); - - for (SysEquipmentVo item : sysEquipmentVos) { - //构建查询属性参数 - SnapshotValueQueryParam snapshotValueQueryParam = new SnapshotValueQueryParam(); - snapshotValueQueryParam.setAttributes(attributesList); - snapshotValueQueryParam.setDeviceId(item.getId().toString()); - paramList.add(snapshotValueQueryParam); - //构建风机数据返回 - WindTurbinesPageVo windTurbinesPageVo = new WindTurbinesPageVo(); - windTurbinesPageVo.setIrn(item.getId()); - windTurbinesPageVo.setName(item.getName()); - windTurbinesPageVo.setModel(item.getModel()); - windTurbinesPageVo.setModelId(item.getIotModelId()); - windTurbinesPageVo.setBelongLine(item.getBelongLine()); - windTurbinesPageVos.add(windTurbinesPageVo); - - } - //获取设备测点数据 - Map> map = dataServiceImpl.querySnapshotValues(paramList); - for (WindTurbinesPageVo item : windTurbinesPageVos) { - item.setAttributeMap(map.get(item.getIrn().toString())); - } - stopWatch.stop(); - //监控查询时间 - log.debug(stopWatch.prettyPrint(TimeUnit.SECONDS)); - return windTurbinesPageVos; - } +public interface WindTurbinesPageService { + public List queryBelongLines(); + public List queryAllWindTurbinesPages(); } diff --git a/das/src/main/java/com/das/modules/page/service/impl/WindTurbinesPageServiceImpl.java b/das/src/main/java/com/das/modules/page/service/impl/WindTurbinesPageServiceImpl.java new file mode 100644 index 00000000..76eb01a0 --- /dev/null +++ b/das/src/main/java/com/das/modules/page/service/impl/WindTurbinesPageServiceImpl.java @@ -0,0 +1,122 @@ +package com.das.modules.page.service.impl; + +import com.das.common.constant.EquipmentTypeIds; +import com.das.modules.data.domain.SnapshotValueQueryParam; +import com.das.modules.data.service.impl.DataServiceImpl; +import com.das.modules.equipment.domain.dto.SysEquipmentDto; +import com.das.modules.equipment.domain.vo.SysEquipmentVo; +import com.das.modules.equipment.mapper.SysEquipmentMapper; +import com.das.modules.operation.service.OperationService; +import com.das.modules.page.domian.WindTurbinesPageVo; +import com.das.modules.page.service.WindTurbinesPageService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StopWatch; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Transactional(rollbackFor = Exception.class) +@Service +@Slf4j +public class WindTurbinesPageServiceImpl implements WindTurbinesPageService { + + @Autowired + SysEquipmentMapper sysEquipmentMapper; + + @Autowired + private DataServiceImpl dataServiceImpl; + + @Autowired + OperationService optService; + + /** + * 获取风机机组所属线路列表 + * + * @return 返回字符串数组 + */ + @Override + public List queryBelongLines() { + return sysEquipmentMapper.queryBelongLines(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG); + } + + + /** + * 获取风机页面数据 + * + * @return 返回风机页面数据 + */ + @Override + public List queryAllWindTurbinesPages() { + StopWatch stopWatch = new StopWatch(); + stopWatch.start("获取风机页面数据"); + SysEquipmentDto sysEquipmentDto = new SysEquipmentDto(); + sysEquipmentDto.setObjectType(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG); + List sysEquipmentVos = sysEquipmentMapper.queryEquipmentListInPage(sysEquipmentDto); + //风机返回数据列表 + List windTurbinesPageVos = new ArrayList<>(); + List paramList = new ArrayList<>(); + //构建需要查询的物模型属性 + List attributesList = new ArrayList<>(); + //风速 + attributesList.add("iwindspeed"); + //风机状态 + attributesList.add("iturbineoperationmode"); + //有功功率(MW) + attributesList.add("igenpower"); + //日发电量(kwh) + attributesList.add("ikwhthisday"); + //总发电量(万kwh) + attributesList.add("ikwhoverall"); + //机舱角度 + attributesList.add("ivanedirection"); + //叶轮转速(rmp) + attributesList.add("irotorspeed"); + //发电机转速(rmp) + attributesList.add("igenspeed"); + //机舱温度(℃) + attributesList.add("itempnacelle_1sec"); + //主油路压力(kpa) + attributesList.add("ihydrpress"); + //变桨角度ipitchangle1,ipitchangle2,ipitchangle3(取最小值) + attributesList.add("ipitchangle1"); + attributesList.add("ipitchangle2"); + attributesList.add("ipitchangle3"); + //解缆状态 + attributesList.add("iyplevel"); + //电网故障停机 + attributesList.add("gridlostdetected"); + //是否锁定 + attributesList.add("Locked"); + + for (SysEquipmentVo item : sysEquipmentVos) { + //构建查询属性参数 + SnapshotValueQueryParam snapshotValueQueryParam = new SnapshotValueQueryParam(); + snapshotValueQueryParam.setAttributes(attributesList); + snapshotValueQueryParam.setDeviceId(item.getId().toString()); + paramList.add(snapshotValueQueryParam); + //构建风机数据返回 + WindTurbinesPageVo windTurbinesPageVo = new WindTurbinesPageVo(); + windTurbinesPageVo.setIrn(item.getId()); + windTurbinesPageVo.setName(item.getName()); + windTurbinesPageVo.setModel(item.getModel()); + windTurbinesPageVo.setModelId(item.getIotModelId()); + windTurbinesPageVo.setBelongLine(item.getBelongLine()); + windTurbinesPageVos.add(windTurbinesPageVo); + + } + //获取设备测点数据 + Map> map = dataServiceImpl.querySnapshotValues(paramList); + for (WindTurbinesPageVo item : windTurbinesPageVos) { + item.setAttributeMap(map.get(item.getIrn().toString())); + } + stopWatch.stop(); + //监控查询时间 + log.debug(stopWatch.prettyPrint(TimeUnit.SECONDS)); + return windTurbinesPageVos; + } +} From efd0f66ad9528caabcbf83cd7ce3ed4c01da5127 Mon Sep 17 00:00:00 2001 From: huguanghan Date: Tue, 5 Nov 2024 16:34:53 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20=E7=A1=AE=E8=AE=A4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/data/domain/DeviceEventInfo.java | 2 - .../modules/data/service/TDEngineService.java | 47 +++++++++++++++++-- .../event/controller/EventController.java | 5 +- .../modules/event/domain/EventQueryParam.java | 14 +++++- .../modules/event/service/EventService.java | 3 +- .../event/service/impl/EventServiceImpl.java | 11 +++-- 6 files changed, 69 insertions(+), 13 deletions(-) diff --git a/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java b/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java index 7f523ced..f50dfd71 100644 --- a/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java +++ b/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java @@ -6,10 +6,8 @@ import lombok.Data; @Data public class DeviceEventInfo { - @JsonSerialize(using = ToStringSerializer.class) private Long eventTime; - @JsonSerialize(using = ToStringSerializer.class) private Long eventId; private Integer eventType; diff --git a/das/src/main/java/com/das/modules/data/service/TDEngineService.java b/das/src/main/java/com/das/modules/data/service/TDEngineService.java index 71386e74..e2fe31c1 100644 --- a/das/src/main/java/com/das/modules/data/service/TDEngineService.java +++ b/das/src/main/java/com/das/modules/data/service/TDEngineService.java @@ -2,6 +2,7 @@ package com.das.modules.data.service; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.StrUtil; +import com.das.common.utils.PageDataInfo; import com.das.modules.data.domain.DeviceEventInfo; import com.das.modules.data.service.impl.DataServiceImpl; import com.das.modules.equipment.domain.vo.IotModelFieldVo; @@ -609,9 +610,10 @@ public class TDEngineService { return result; } - public List queryEvent(Integer eventLevel, Long startTime, Long endTime, List deviceCodeList) { + public PageDataInfo queryEvent(Integer eventLevel, Long startTime, Long endTime, List deviceCodeList, Integer limit, Integer offset) { List result = new ArrayList<>(); StringBuffer sb = new StringBuffer(2048); + Integer total = 0; sb.append("select t.* from event_info t where "); sb.append(String.format(" t.event_time >= %d and t.event_time < %d", startTime, endTime)); if (eventLevel != null) { @@ -628,7 +630,13 @@ public class TDEngineService { } } sb.append(" order by t.event_time"); + if (limit != null){ + sb.append(" limit ").append(offset).append(",").append(limit); + total = getEventCount(eventLevel,startTime,endTime,deviceCodeList); + } + log.debug(sb.toString()); + try (Connection conn = hikariDataSource.getConnection(); Statement smt = conn.createStatement(); ResultSet rs = smt.executeQuery(sb.toString())) { @@ -648,9 +656,42 @@ public class TDEngineService { } } catch (Exception e) { log.error("获取数据异常", e); - return result; + return PageDataInfo.build(result, total); } - return result; + return PageDataInfo.build(result, total); + } + + private Integer getEventCount(Integer eventLevel, Long startTime, Long endTime, List deviceCodeList){ + List result = new ArrayList<>(); + StringBuffer sb = new StringBuffer(2048); + sb.append("select count(t.*) as total from event_info t where "); + sb.append(String.format(" t.event_time >= %d and t.event_time < %d", startTime, endTime)); + if (eventLevel != null) { + sb.append(String.format(" and t.event_level = %d", eventLevel)); + } + if (!CollectionUtils.isEmpty(deviceCodeList)) { + sb.append(" and t.device_code in ("); + for (int i = 0; i < deviceCodeList.size(); i++) { + if (i == deviceCodeList.size() - 1) { + sb.append("'").append(deviceCodeList.get(i)).append("')"); + } else { + sb.append("'").append(deviceCodeList.get(i)).append("',"); + } + } + } + log.debug(sb.toString()); + Integer total = null; + try (Connection conn = hikariDataSource.getConnection(); + Statement smt = conn.createStatement(); + ResultSet rs = smt.executeQuery(sb.toString())) { + + while (rs.next()) { + total = rs.getInt("total"); + } + } catch (Exception e) { + log.error("获取数据异常", e); + } + return total; } public void confirmEvent(DeviceEventInfo deviceEventInfo) { diff --git a/das/src/main/java/com/das/modules/event/controller/EventController.java b/das/src/main/java/com/das/modules/event/controller/EventController.java index e19af6d0..9c6e3e45 100644 --- a/das/src/main/java/com/das/modules/event/controller/EventController.java +++ b/das/src/main/java/com/das/modules/event/controller/EventController.java @@ -2,6 +2,7 @@ package com.das.modules.event.controller; import com.das.common.result.R; import com.das.common.utils.JsonUtils; +import com.das.common.utils.PageDataInfo; import com.das.modules.data.domain.DeviceEventInfo; import com.das.modules.event.domain.EventQueryParam; import com.das.modules.event.service.EventService; @@ -33,12 +34,12 @@ public class EventController { * @return TD数据库数据 */ @PostMapping("/query") - public R> queryEvent(@RequestBody @Valid EventQueryParam param) { + public PageDataInfo queryEvent(@RequestBody @Valid EventQueryParam param) { if (log.isDebugEnabled()){ log.debug("/api/event/query is calling"); log.debug(JsonUtils.toJsonString(param)); } - return R.success(eventService.queryEvent(param)); + return eventService.queryEvent(param); } /** diff --git a/das/src/main/java/com/das/modules/event/domain/EventQueryParam.java b/das/src/main/java/com/das/modules/event/domain/EventQueryParam.java index c4946328..e11be94b 100644 --- a/das/src/main/java/com/das/modules/event/domain/EventQueryParam.java +++ b/das/src/main/java/com/das/modules/event/domain/EventQueryParam.java @@ -14,12 +14,12 @@ public class EventQueryParam /** * 开始时间 */ - private String startTime; + private Long startTime; /** * 结束时间 */ - private String endTime; + private Long endTime; /** * 事件等级 @@ -30,4 +30,14 @@ public class EventQueryParam * 设备编码列表 */ private List deviceCode; + + /** + * pageNum; + */ + private Integer pageNum; + + /** + * pageSize + */ + private Integer pageSize; } diff --git a/das/src/main/java/com/das/modules/event/service/EventService.java b/das/src/main/java/com/das/modules/event/service/EventService.java index ee777d12..89e86126 100644 --- a/das/src/main/java/com/das/modules/event/service/EventService.java +++ b/das/src/main/java/com/das/modules/event/service/EventService.java @@ -1,5 +1,6 @@ package com.das.modules.event.service; +import com.das.common.utils.PageDataInfo; import com.das.modules.data.domain.DeviceEventInfo; import com.das.modules.event.domain.EventQueryParam; import org.springframework.web.bind.annotation.RequestBody; @@ -7,7 +8,7 @@ import org.springframework.web.bind.annotation.RequestBody; import java.util.List; public interface EventService { - List queryEvent(EventQueryParam param); + PageDataInfo queryEvent(EventQueryParam param); void confirmEvent(List deviceEventInfoList); } diff --git a/das/src/main/java/com/das/modules/event/service/impl/EventServiceImpl.java b/das/src/main/java/com/das/modules/event/service/impl/EventServiceImpl.java index 04da4c80..00d1e2b3 100644 --- a/das/src/main/java/com/das/modules/event/service/impl/EventServiceImpl.java +++ b/das/src/main/java/com/das/modules/event/service/impl/EventServiceImpl.java @@ -3,6 +3,7 @@ package com.das.modules.event.service.impl; import cn.dev33.satoken.stp.StpUtil; import com.das.common.config.SessionUtil; import com.das.common.exceptions.ServiceException; +import com.das.common.utils.PageDataInfo; import com.das.modules.auth.domain.vo.SysUserVo; import com.das.modules.data.domain.DeviceEventInfo; import com.das.modules.data.service.TDEngineService; @@ -22,11 +23,15 @@ public class EventServiceImpl implements EventService { private TDEngineService tdEngineService; @Override - public List queryEvent(EventQueryParam param) { - if (param.getStartTime() == null || param.getEndTime() ==null){ + public PageDataInfo queryEvent(EventQueryParam param) { + if (param.getStartTime() == null || param.getEndTime() == null) { throw new ServiceException("查询时间不能为空"); } - List deviceEventInfos = tdEngineService.queryEvent(param.getEventLevel(), Long.valueOf(param.getStartTime()), Long.valueOf(param.getEndTime()), param.getDeviceCode()); + Integer offset = null; + if (param.getPageNum() != null) { + offset = (param.getPageNum() - 1) * param.getPageSize(); + } + PageDataInfo deviceEventInfos = tdEngineService.queryEvent(param.getEventLevel(), param.getStartTime(), param.getEndTime(), param.getDeviceCode(), param.getPageSize(), offset); return deviceEventInfos; } From 53381134ebfe5a35e2d17d29def8cc6d7f80d429 Mon Sep 17 00:00:00 2001 From: huguanghan Date: Tue, 5 Nov 2024 16:37:05 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20=E7=A1=AE=E8=AE=A4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/das/modules/data/domain/DeviceEventInfo.java | 1 + 1 file changed, 1 insertion(+) diff --git a/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java b/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java index f50dfd71..b9a983e8 100644 --- a/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java +++ b/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java @@ -8,6 +8,7 @@ import lombok.Data; public class DeviceEventInfo { private Long eventTime; + @JsonSerialize(using = ToStringSerializer.class) private Long eventId; private Integer eventType; From 5e6d79ce051cb88d38da2c320f96bf9d9372245b Mon Sep 17 00:00:00 2001 From: huguanghan Date: Tue, 5 Nov 2024 16:39:49 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20=E7=A1=AE=E8=AE=A4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/das/modules/data/domain/DeviceEventInfo.java | 1 - 1 file changed, 1 deletion(-) diff --git a/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java b/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java index b9a983e8..86d06672 100644 --- a/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java +++ b/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java @@ -21,7 +21,6 @@ public class DeviceEventInfo { private String confirmAccount; - @JsonSerialize(using = ToStringSerializer.class) private Long confirmTime; private String deviceId; From 5736768af4f2ba534da5761a337bc4bac927d719 Mon Sep 17 00:00:00 2001 From: huguanghan Date: Tue, 5 Nov 2024 16:53:31 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/_sidebar.md | 1 + docs/api/event.md | 118 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 docs/api/event.md diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 9375cbe0..c69f9092 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -7,6 +7,7 @@ - [数据字段接口](api/enumPage.md) - [人工操作接口](api/operation.md) - [页面访问接口](api/pages/) + - [告警事件接口](api/event.md) - [首页接口](api/pages/home.md) - [数据采集](datacollect/) - [系统部署](deploy/) diff --git a/docs/api/event.md b/docs/api/event.md new file mode 100644 index 00000000..e643552f --- /dev/null +++ b/docs/api/event.md @@ -0,0 +1,118 @@ +# 告警相关模块 + +## API接口一览表 + +| 接口分类 | 接口描述 | API接口 | 权限 | +|---------|-----------------| ------------------------------------- | --------------------------- | +| 1.1告警相关操作 | 1.1.1查询设备告警信息列表 | /api/event/query | | +| | 1.2.1确认告警信息 | /api/event/confirm | | +| | | | | + + +### 1.1 告警相关操作接口 + +#### 1.1.1查询设备告警信息列表 + +POST 请求接口 + +> /api/event/query + +请求参数 + +```json +{ + "startTime":1730778600161, + "endTime":1730779105676, + "eventLevel": 0, + "deviceCode":["A-001"], + "pageNum": 1, + "pageSize": 10 +} +``` +入参描述 + +| 参数名 | 参数类型 | 必填 | 描述 | +| ------------ |---------|-----|--------| +| startTime | Long | True | 开始时间 | +| endTime | Long | True | 结束时间 | +| eventLevel | int | False | 事件等级0:告警,1:故障 | +| deviceCode | List | True | 设备编码数组 | +| pageNum | Integer | NO | 当前页 | +| pageSize | Integer | NO | 每页显示大小 | + +返回报文 + +```json +{ + "total": 10501, + "rows": [ + { + "eventTime": 1730778601000, + "eventId": "1853647068678127617", + "eventType": 0, + "eventLevel": 0, + "eventText": "风机由于变桨系统安全链断开导致机组急停 动作", + "confirmed": 1, + "confirmAccount": "null", + "confirmTime": 1730789465314, + "deviceId": "1846101273013739522", + "deviceCode": "A-001" + }, + { + "eventTime": 1730778601000, + "eventId": "1853647068678127618", + "eventType": 0, + "eventLevel": 0, + "eventText": "风机轮毂温度>60℃ 复归", + "confirmed": 0, + "confirmTime": 0, + "deviceId": "1846101273013739522", + "deviceCode": "A-001" + } + ], + "code": 200, + "msg": "查询成功" +} +``` + + + + +#### 1.1.2 确认告警信息 + +POST 请求接口 + +> /api/event/confirm + +请求参数 + +```json +[ + { + "eventTime": 1730778601000, + "eventId": "1853647068678127617", + "confirmed": 1, + "deviceId": "1846101273013739522" + } +] +``` +入参描述 + +| 参数名 | 参数类型 | 必填 | 描述 | +| ------------ |---------|-----|------| +| eventTime | Long | true | 事件时间 | +| eventId | String | true | 事件id | +| confirmed | int | true | 是否确认:0不确认,1确认 | +| deviceId | String | true | 设备id | + +返回报文 + +```json +{ + "code": 200, + "success": true, + "msg": "操作成功" +} +``` + + From 49cf55856ca26310a59a87bd578aba6a6c10e218 Mon Sep 17 00:00:00 2001 From: huguanghan Date: Tue, 5 Nov 2024 16:55:05 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20=E7=A1=AE=E8=AE=A4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/das/modules/event/controller/EventController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/das/src/main/java/com/das/modules/event/controller/EventController.java b/das/src/main/java/com/das/modules/event/controller/EventController.java index 9c6e3e45..138df066 100644 --- a/das/src/main/java/com/das/modules/event/controller/EventController.java +++ b/das/src/main/java/com/das/modules/event/controller/EventController.java @@ -44,7 +44,7 @@ public class EventController { /** * 确认告警信息 - * @param deviceEventInfo 确认信息 + * @param deviceEventInfoList 确认信息 */ @PostMapping("/confirm") public R confirmEvent(@RequestBody List deviceEventInfoList){ From 6ea18e89b50e88fc1119724fdff2b9f7308e4a20 Mon Sep 17 00:00:00 2001 From: geting <13585118195@163.com> Date: Tue, 5 Nov 2024 17:11:18 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/dasadmin/src/api/backend/alarms/request.ts | 10 +- .../src/views/backend/alarms/index.vue | 188 +++++++++++------- ui/dasadmin/src/views/backend/alarms/type.ts | 12 +- 3 files changed, 132 insertions(+), 78 deletions(-) diff --git a/ui/dasadmin/src/api/backend/alarms/request.ts b/ui/dasadmin/src/api/backend/alarms/request.ts index c0d1c07d..3a26e635 100644 --- a/ui/dasadmin/src/api/backend/alarms/request.ts +++ b/ui/dasadmin/src/api/backend/alarms/request.ts @@ -4,7 +4,15 @@ import { RequestReturnRowType, GetAlarmsTableParam, AlarmsTableType } from '/@/v // 告警列表 export const getAlarmListReq = (data: GetAlarmsTableParam) => { return createAxios>({ - url: '/api/alarm/list', + url: 'api/event/query', + method: 'post', + data: data, + }) +} + +export const eventComfirm = (data: any) => { + return createAxios>({ + url: '/api/event/confirm', method: 'post', data: data, }) diff --git a/ui/dasadmin/src/views/backend/alarms/index.vue b/ui/dasadmin/src/views/backend/alarms/index.vue index 1c1aa3b0..b5d49076 100644 --- a/ui/dasadmin/src/views/backend/alarms/index.vue +++ b/ui/dasadmin/src/views/backend/alarms/index.vue @@ -7,12 +7,12 @@
@@ -32,15 +32,20 @@
- - - - - + + + + + + @@ -65,13 +70,12 @@ @@ -294,6 +320,22 @@ $paginationHeight: 32px; } .tablePart { height: 100%; + .alarm { + border: 1px solid rgb(228, 161, 18); + width: fit-content; + margin: 0 auto; + padding: 5px; + border-radius: 6px; + color: rgb(228, 161, 18); + } + .fault { + border: 1px solid #a03b1d; + width: fit-content; + margin: 0 auto; + padding: 5px; + border-radius: 6px; + color: #a03b1d; + } } .tableOperate { display: flex; @@ -307,6 +349,10 @@ $paginationHeight: 32px; cursor: pointer; } } + &.comfirmed { + font-weight: 600; + color: rgb(5, 174, 163); + } } } .mainFooter { diff --git a/ui/dasadmin/src/views/backend/alarms/type.ts b/ui/dasadmin/src/views/backend/alarms/type.ts index 5bbfe03d..9aa9bc17 100644 --- a/ui/dasadmin/src/views/backend/alarms/type.ts +++ b/ui/dasadmin/src/views/backend/alarms/type.ts @@ -20,12 +20,12 @@ export type AlarmsTableType = { alarmType: string } export type GetAlarmsTableParam = { - startTime: string - endTime: string - airBlowerNumber: string - alarmType: string - pageNum: number - pageSize: number + startTime: string | number + endTime: string | number + deviceCode: any + eventLevel: string | null + pageNum: Number + pageSize: Number } export enum AlarmsFieldsEnums { From 48e5ab1babda83b4318910c5d7ad5549c848b63a Mon Sep 17 00:00:00 2001 From: geting <13585118195@163.com> Date: Tue, 5 Nov 2024 17:26:57 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/backend/alarms/index.vue | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ui/dasadmin/src/views/backend/alarms/index.vue b/ui/dasadmin/src/views/backend/alarms/index.vue index b5d49076..6c8fc56b 100644 --- a/ui/dasadmin/src/views/backend/alarms/index.vue +++ b/ui/dasadmin/src/views/backend/alarms/index.vue @@ -46,7 +46,7 @@ @@ -71,7 +71,7 @@