Merge branch 'main' of https://git.jsspisoft.com/ry-das
This commit is contained in:
commit
1c4dc03363
@ -6,7 +6,6 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeviceEventInfo {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long eventTime;
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@ -22,7 +21,6 @@ public class DeviceEventInfo {
|
||||
|
||||
private String confirmAccount;
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long confirmTime;
|
||||
|
||||
private String deviceId;
|
||||
|
@ -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<DeviceEventInfo> queryEvent(Integer eventLevel, Long startTime, Long endTime, List<String> deviceCodeList) {
|
||||
public PageDataInfo<DeviceEventInfo> queryEvent(Integer eventLevel, Long startTime, Long endTime, List<String> deviceCodeList, Integer limit, Integer offset) {
|
||||
List<DeviceEventInfo> 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<String> deviceCodeList){
|
||||
List<DeviceEventInfo> 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) {
|
||||
|
@ -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,21 +34,21 @@ public class EventController {
|
||||
* @return TD数据库数据
|
||||
*/
|
||||
@PostMapping("/query")
|
||||
public R<List<DeviceEventInfo>> queryEvent(@RequestBody @Valid EventQueryParam param) {
|
||||
public PageDataInfo<DeviceEventInfo> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认告警信息
|
||||
* @param deviceEventInfo 确认信息
|
||||
* @param deviceEventInfoList 确认信息
|
||||
*/
|
||||
@PostMapping("/confirm")
|
||||
public R<Void> confirmEvent(@RequestBody DeviceEventInfo deviceEventInfo){
|
||||
eventService.confirmEvent(deviceEventInfo);
|
||||
public R<Void> confirmEvent(@RequestBody List<DeviceEventInfo> deviceEventInfoList){
|
||||
eventService.confirmEvent(deviceEventInfoList);
|
||||
return R.success();
|
||||
}
|
||||
}
|
||||
|
@ -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<String> deviceCode;
|
||||
|
||||
/**
|
||||
* pageNum;
|
||||
*/
|
||||
private Integer pageNum;
|
||||
|
||||
/**
|
||||
* pageSize
|
||||
*/
|
||||
private Integer pageSize;
|
||||
}
|
||||
|
@ -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<DeviceEventInfo> queryEvent(EventQueryParam param);
|
||||
PageDataInfo<DeviceEventInfo> queryEvent(EventQueryParam param);
|
||||
|
||||
void confirmEvent(DeviceEventInfo deviceEventInfo);
|
||||
void confirmEvent(List<DeviceEventInfo> deviceEventInfoList);
|
||||
}
|
||||
|
@ -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,20 +23,26 @@ public class EventServiceImpl implements EventService {
|
||||
private TDEngineService tdEngineService;
|
||||
|
||||
@Override
|
||||
public List<DeviceEventInfo> queryEvent(EventQueryParam param) {
|
||||
if (param.getStartTime() == null || param.getEndTime() ==null){
|
||||
public PageDataInfo<DeviceEventInfo> queryEvent(EventQueryParam param) {
|
||||
if (param.getStartTime() == null || param.getEndTime() == null) {
|
||||
throw new ServiceException("查询时间不能为空");
|
||||
}
|
||||
List<DeviceEventInfo> 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<DeviceEventInfo> deviceEventInfos = tdEngineService.queryEvent(param.getEventLevel(), param.getStartTime(), param.getEndTime(), param.getDeviceCode(), param.getPageSize(), offset);
|
||||
return deviceEventInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirmEvent(DeviceEventInfo deviceEventInfo) {
|
||||
public void confirmEvent(List<DeviceEventInfo> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.*;
|
||||
@ -42,15 +39,4 @@ public class WindTurbinesPageController {
|
||||
List<WindTurbinesPageVo> windTurbinesPageVos = windTurbinesPageService.queryAllWindTurbinesPages();
|
||||
return R.success(windTurbinesPageVos);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param controlList 遥控List
|
||||
* @return 成功或者失败
|
||||
*/
|
||||
@PostMapping ("/windTurbinesControl")
|
||||
public R<Void> windTurbinesControl(HttpServletRequest request ,@RequestBody List<CommandInfoDto> controlList){
|
||||
windTurbinesPageService.windTurbinesControl(request,controlList);
|
||||
return R.success();
|
||||
}
|
||||
}
|
||||
|
@ -1,135 +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<String> queryBelongLines() {
|
||||
return sysEquipmentMapper.queryBelongLines(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取风机页面数据
|
||||
*
|
||||
* @return 返回风机页面数据
|
||||
*/
|
||||
public List<WindTurbinesPageVo> queryAllWindTurbinesPages() {
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start("获取风机页面数据");
|
||||
SysEquipmentDto sysEquipmentDto = new SysEquipmentDto();
|
||||
sysEquipmentDto.setObjectType(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG);
|
||||
List<SysEquipmentVo> sysEquipmentVos = sysEquipmentMapper.queryEquipmentListInPage(sysEquipmentDto);
|
||||
//风机返回数据列表
|
||||
List<WindTurbinesPageVo> windTurbinesPageVos = new ArrayList<>();
|
||||
List<SnapshotValueQueryParam> paramList = new ArrayList<>();
|
||||
//构建需要查询的物模型属性
|
||||
List<String> 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<String, Map<String, Object>> 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 void windTurbinesControl(HttpServletRequest request,List<CommandInfoDto> controlList) {
|
||||
for (CommandInfoDto item : controlList) {
|
||||
try {
|
||||
optService.executeOperation(request,item);
|
||||
} catch (Exception e) {
|
||||
log.error("下控失败", e);
|
||||
throw new ServiceException("下控失败" + e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public interface WindTurbinesPageService {
|
||||
public List<String> queryBelongLines();
|
||||
public List<WindTurbinesPageVo> queryAllWindTurbinesPages();
|
||||
}
|
||||
|
@ -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<String> queryBelongLines() {
|
||||
return sysEquipmentMapper.queryBelongLines(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取风机页面数据
|
||||
*
|
||||
* @return 返回风机页面数据
|
||||
*/
|
||||
@Override
|
||||
public List<WindTurbinesPageVo> queryAllWindTurbinesPages() {
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start("获取风机页面数据");
|
||||
SysEquipmentDto sysEquipmentDto = new SysEquipmentDto();
|
||||
sysEquipmentDto.setObjectType(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG);
|
||||
List<SysEquipmentVo> sysEquipmentVos = sysEquipmentMapper.queryEquipmentListInPage(sysEquipmentDto);
|
||||
//风机返回数据列表
|
||||
List<WindTurbinesPageVo> windTurbinesPageVos = new ArrayList<>();
|
||||
List<SnapshotValueQueryParam> paramList = new ArrayList<>();
|
||||
//构建需要查询的物模型属性
|
||||
List<String> 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<String, Map<String, Object>> 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;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@
|
||||
- [数据字段接口](api/enumPage.md)
|
||||
- [人工操作接口](api/operation.md)
|
||||
- [页面访问接口](api/pages/)
|
||||
- [告警事件接口](api/event.md)
|
||||
- [首页接口](api/pages/home.md)
|
||||
- [数据采集](datacollect/)
|
||||
- [系统部署](deploy/)
|
||||
|
118
docs/api/event.md
Normal file
118
docs/api/event.md
Normal file
@ -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": "操作成功"
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -4,7 +4,15 @@ import { RequestReturnRowType, GetAlarmsTableParam, AlarmsTableType } from '/@/v
|
||||
// 告警列表
|
||||
export const getAlarmListReq = (data: GetAlarmsTableParam) => {
|
||||
return createAxios<never, RequestReturnRowType<AlarmsTableType[]>>({
|
||||
url: '/api/alarm/list',
|
||||
url: 'api/event/query',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const eventComfirm = (data: any) => {
|
||||
return createAxios<never, RequestReturnRowType<any>>({
|
||||
url: '/api/event/confirm',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
|
@ -7,12 +7,12 @@
|
||||
<el-date-picker
|
||||
style="height: 40px"
|
||||
v-model="timeRange"
|
||||
type="daterange"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
type="datetimerange"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
range-separator="-"
|
||||
:start-placeholder="t('alarm.selectDate')"
|
||||
:end-placeholder="t('alarm.selectDate')"
|
||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
|
||||
:shortcuts="shortcuts"
|
||||
/>
|
||||
<div style="width: 20px"></div>
|
||||
@ -32,16 +32,21 @@
|
||||
<el-main class="mainMain">
|
||||
<div class="tabsPart">
|
||||
<el-table :data="alarmsTableData" class="tablePart" highlight-current-row>
|
||||
<el-table-column prop="alarmTime" :label="AlarmsFieldsEnums['alarmTime']" align="center"> </el-table-column>
|
||||
<el-table-column prop="airBlowerNumber" :label="AlarmsFieldsEnums['airBlowerNumber']" align="center"> </el-table-column>
|
||||
<el-table-column prop="faultDescription" :label="AlarmsFieldsEnums['faultDescription']" align="center"> </el-table-column>
|
||||
<el-table-column prop="alarmGrade" :label="AlarmsFieldsEnums['alarmGrade']" align="center"> </el-table-column>
|
||||
<el-table-column prop="alarmType" :label="AlarmsFieldsEnums['alarmType']" align="center"> </el-table-column>
|
||||
<el-table-column prop="eventTimeFormate" :label="AlarmsFieldsEnums['alarmTime']" align="center"> </el-table-column>
|
||||
<el-table-column prop="deviceCode" :label="AlarmsFieldsEnums['airBlowerNumber']" align="center"> </el-table-column>
|
||||
<el-table-column prop="eventText" :label="AlarmsFieldsEnums['faultDescription']" align="center"> </el-table-column>
|
||||
<el-table-column prop="eventType" :label="AlarmsFieldsEnums['alarmType']" align="center">
|
||||
<template #default="scope">
|
||||
<div class="fault" v-if="scope.row.eventType">故障</div>
|
||||
<div class="alarm" v-else>告警</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="操作" width="200" align="center">
|
||||
<template #default="scope">
|
||||
<div class="tableOperate">
|
||||
<a @click="okSubmit(scope.row)">确认</a>
|
||||
<div class="tableOperate comfirmed" v-if="scope.row.confirmed">已确认</div>
|
||||
<div class="tableOperate" v-else>
|
||||
<a @click="open(scope.row)">确认</a>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -65,13 +70,12 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, nextTick, onMounted } from 'vue'
|
||||
import { ElMessage, TableInstance, TreeInstance } from 'element-plus'
|
||||
import { reactive, ref, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Search } from '@element-plus/icons-vue'
|
||||
import { AlarmsFieldsEnums, AlarmsTableType, GetAlarmsTableParam } from './type'
|
||||
import { getAlarmListReq } from '/@/api/backend/alarms/request'
|
||||
import { equipList } from '/@/api/backend/realData/request.ts'
|
||||
import { debounce, cloneDeep } from 'lodash'
|
||||
import { getAlarmListReq, eventComfirm } from '/@/api/backend/alarms/request'
|
||||
import { equipList } from '/@/api/backend/realData/request'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
const { t } = useI18n()
|
||||
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||
@ -79,32 +83,29 @@ const adminInfo = useAdminInfo()
|
||||
|
||||
// 告警时间
|
||||
|
||||
const timeRange = ref([])
|
||||
const timeRange = ref([new Date().setHours(0, 0, 0, 0), new Date()])
|
||||
const shortcuts = [
|
||||
{
|
||||
text: '今天',
|
||||
value: () => {
|
||||
const start = getFormattedDate(0) + ' 00:00:00'
|
||||
const end = new Date()
|
||||
const start = new Date()
|
||||
return [start, end]
|
||||
},
|
||||
},
|
||||
{
|
||||
text: '昨天',
|
||||
value: () => {
|
||||
const end = new Date()
|
||||
end.setDate(end.getDate() - 1)
|
||||
const start = new Date()
|
||||
start.setDate(start.getDate() - 1)
|
||||
const start = getFormattedDate(-1) + ' 00:00:00'
|
||||
const end = getFormattedDate(-1) + ' 23:59:59'
|
||||
return [start, end]
|
||||
},
|
||||
},
|
||||
{
|
||||
text: '前3天',
|
||||
value: () => {
|
||||
const end = new Date()
|
||||
const start = new Date()
|
||||
start.setDate(start.getDate() - 2)
|
||||
const start = getFormattedDate(-3) + ' 00:00:00'
|
||||
const end = getFormattedDate(-1) + ' 23:59:59'
|
||||
return [start, end]
|
||||
},
|
||||
},
|
||||
@ -121,6 +122,15 @@ const shortcuts = [
|
||||
},
|
||||
},
|
||||
]
|
||||
const getFormattedDate = (offset: number) => {
|
||||
const date = new Date()
|
||||
date.setDate(date.getDate() + offset)
|
||||
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
|
||||
// 风机编号
|
||||
const airBlowerNumberValue = ref('')
|
||||
@ -128,18 +138,26 @@ const airBlowerList = ref([{ label: '', value: '' }])
|
||||
// 类别
|
||||
const alarmTypeValue = ref('')
|
||||
const alarmTypes = ref([
|
||||
{ label: '告警', value: 0 },
|
||||
{ label: '故障', value: 1 },
|
||||
{ label: '告警', value: 2 },
|
||||
])
|
||||
|
||||
const searchalarms = (): GetAlarmsTableParam => {
|
||||
const start = timeRange.value[0]
|
||||
const end = timeRange.value[1]
|
||||
const deviceCode: any = []
|
||||
if (airBlowerNumberValue.value.length) {
|
||||
deviceCode.push(airBlowerNumberValue.value)
|
||||
} else {
|
||||
airBlowerList.value.forEach((item: any) => {
|
||||
deviceCode.push(item.value)
|
||||
})
|
||||
}
|
||||
return {
|
||||
startTime: start || '',
|
||||
endTime: end || '',
|
||||
airBlowerNumber: airBlowerNumberValue.value,
|
||||
alarmType: alarmTypeValue.value,
|
||||
startTime: new Date(start).getTime() || new Date().setHours(0, 0, 0, 0).valueOf(),
|
||||
endTime: new Date(end).getTime() || new Date().valueOf(),
|
||||
eventLevel: alarmTypeValue.value || null,
|
||||
deviceCode: deviceCode,
|
||||
pageNum: paginationOptions.current,
|
||||
pageSize: paginationOptions.pageSize,
|
||||
}
|
||||
@ -160,49 +178,74 @@ const getcurrentPage = () => {
|
||||
|
||||
const getalarmsList = () => {
|
||||
const transparams = searchalarms()
|
||||
console.log('🚀 ~ getalarmsList ~ transparams:', transparams)
|
||||
setTimeout(() => {
|
||||
alarmsTableData.value = [
|
||||
{
|
||||
alarmTime: '2024-09-30 14:08:00',
|
||||
airBlowerNumber: 'sc-001',
|
||||
faultDescription: '变桨轴1处于紧急模式',
|
||||
alarmGrade: '一级',
|
||||
alarmType: '故障',
|
||||
},
|
||||
{
|
||||
alarmTime: '2024-09-30 14:08:00',
|
||||
airBlowerNumber: 'sc-001',
|
||||
faultDescription: '变桨轴1处于紧急模式',
|
||||
alarmGrade: '一级',
|
||||
alarmType: '故障',
|
||||
},
|
||||
{
|
||||
alarmTime: '2024-09-30 14:08:00',
|
||||
airBlowerNumber: 'sc-001',
|
||||
faultDescription: '变桨轴1处于紧急模式',
|
||||
alarmGrade: '一级',
|
||||
alarmType: '故障',
|
||||
},
|
||||
]
|
||||
paginationOptions.total = 3
|
||||
getAlarmListReq(transparams)
|
||||
.then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
paginationOptions.total = res.total
|
||||
alarmsTableData.value = res.rows.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
eventTimeFormate: timestampToTime(item.eventTime),
|
||||
}
|
||||
})
|
||||
} else {
|
||||
ElMessage.error(res.msg ?? '查询失败')
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '查询失败')
|
||||
})
|
||||
}
|
||||
const timestampToTime = (timestamp: any) => {
|
||||
timestamp = timestamp ? timestamp : null
|
||||
let date = new Date(timestamp)
|
||||
let Y = date.getFullYear() + '-'
|
||||
let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
|
||||
let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '
|
||||
let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
|
||||
let m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
|
||||
return Y + M + D + h + m
|
||||
}
|
||||
|
||||
const open = (val: any) => {
|
||||
ElMessageBox.confirm('是否确认?', '提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
// getAlarmListReq(transparams)
|
||||
// .then((res) => {
|
||||
// if (res.rows) {
|
||||
// paginationOptions.total = res.total
|
||||
// } else {
|
||||
// ElMessage.error(res.msg ?? '查询失败')
|
||||
// }
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// ElMessage.error(err?.response?.data?.msg ?? '查询失败')
|
||||
// })
|
||||
.then(() => {
|
||||
okSubmit(val)
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: '取消确认',
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const okSubmit = (val: any) => {
|
||||
console.log(val)
|
||||
getalarmsList()
|
||||
const reqData: any = [
|
||||
{
|
||||
eventTime: val.eventTime,
|
||||
eventId: val.eventId,
|
||||
confirmed: 1,
|
||||
deviceId: val.deviceId,
|
||||
},
|
||||
]
|
||||
|
||||
eventComfirm(reqData)
|
||||
.then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
ElMessage.success(res.msg ?? '确认成功')
|
||||
getalarmsList()
|
||||
} else {
|
||||
ElMessage.error(res.msg ?? '查询失败')
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '查询失败')
|
||||
})
|
||||
}
|
||||
const getDateRange = (type: 'week' | 'month') => {
|
||||
const today = new Date()
|
||||
@ -233,13 +276,13 @@ onMounted(() => {
|
||||
if (res.code == 200) {
|
||||
airBlowerList.value = res.data.map((item: any) => {
|
||||
return {
|
||||
label: item.code,
|
||||
value: item.id,
|
||||
label: item.name,
|
||||
value: item.code,
|
||||
}
|
||||
})
|
||||
getalarmsList()
|
||||
}
|
||||
})
|
||||
getalarmsList()
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -294,6 +337,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 +366,10 @@ $paginationHeight: 32px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
&.comfirmed {
|
||||
font-weight: 600;
|
||||
color: rgb(5, 174, 163);
|
||||
}
|
||||
}
|
||||
}
|
||||
.mainFooter {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user