环境数据展示
This commit is contained in:
parent
ed03583917
commit
b961a45d4c
@ -46,6 +46,13 @@ public class DeviceWorkDataController {
|
|||||||
return ResponseResult.successData(deviceWorkDataPage);
|
return ResponseResult.successData(deviceWorkDataPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getDeviceWorkData")
|
||||||
|
@ApiOperation("查询变电站设备运行数据")
|
||||||
|
public ResponseResult getDeviceWorkData(String stationId) {
|
||||||
|
List<Map<String, Object>> map = deviceWorkDataService.getDeviceWorkData(stationId);
|
||||||
|
return ResponseResult.successData(map);
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, Object> processDeviceData(List<DeviceWorkData> deviceWorkDataList, String signalId) {
|
public Map<String, Object> processDeviceData(List<DeviceWorkData> deviceWorkDataList, String signalId) {
|
||||||
// 生成过去60分钟的分钟时间槽
|
// 生成过去60分钟的分钟时间槽
|
||||||
LocalDateTime now = LocalDateTime.now().truncatedTo(ChronoUnit.MINUTES);
|
LocalDateTime now = LocalDateTime.now().truncatedTo(ChronoUnit.MINUTES);
|
||||||
@ -109,4 +116,11 @@ public class DeviceWorkDataController {
|
|||||||
return ResponseResult.successData(map);
|
return ResponseResult.successData(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/insertData")
|
||||||
|
@ApiOperation("生成遥测数据")
|
||||||
|
public ResponseResult insertData(String from, String type, String slaveIp, String address, String value) {
|
||||||
|
deviceWorkDataService.insertData(from, type, slaveIp, address, value);
|
||||||
|
return ResponseResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.yfd.platform.modules.auxcontrol.domain.DeviceWorkData;
|
|||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -35,4 +36,5 @@ public interface DeviceWorkDataMapper extends BaseMapper<DeviceWorkData> {
|
|||||||
***********************************/
|
***********************************/
|
||||||
List<DeviceWorkData> getHistoricalCurve(String signalId);
|
List<DeviceWorkData> getHistoricalCurve(String signalId);
|
||||||
|
|
||||||
|
List<Map<String, Object>> getDeviceWorkData(String stationId);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.yfd.platform.modules.auxcontrol.domain.DeviceWorkData;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -45,4 +46,6 @@ public interface IDeviceWorkDataService extends IService<DeviceWorkData> {
|
|||||||
***********************************/
|
***********************************/
|
||||||
List<DeviceWorkData> getHistoricalCurve(String signalId);
|
List<DeviceWorkData> getHistoricalCurve(String signalId);
|
||||||
|
|
||||||
|
List<Map<String, Object>> getDeviceWorkData(String stationId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,4 +94,9 @@ public class DeviceWorkDataServiceImpl extends ServiceImpl<DeviceWorkDataMapper,
|
|||||||
return deviceWorkDataMapper.getHistoricalCurve(signalId);
|
return deviceWorkDataMapper.getHistoricalCurve(signalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getDeviceWorkData(String stationId) {
|
||||||
|
return deviceWorkDataMapper.getDeviceWorkData(stationId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.yfd.platform.modules.basedata.service.impl;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.yfd.platform.modules.auxcontrol.mapper.DeviceWorkDataMapper;
|
||||||
import com.yfd.platform.modules.basedata.domain.WeatherLog;
|
import com.yfd.platform.modules.basedata.domain.WeatherLog;
|
||||||
import com.yfd.platform.modules.basedata.mapper.WeatherLogMapper;
|
import com.yfd.platform.modules.basedata.mapper.WeatherLogMapper;
|
||||||
import com.yfd.platform.modules.basedata.service.IWeatherLogService;
|
import com.yfd.platform.modules.basedata.service.IWeatherLogService;
|
||||||
@ -27,7 +28,7 @@ import java.util.stream.Collectors;
|
|||||||
public class WeatherLogServiceImpl extends ServiceImpl<WeatherLogMapper, WeatherLog> implements IWeatherLogService {
|
public class WeatherLogServiceImpl extends ServiceImpl<WeatherLogMapper, WeatherLog> implements IWeatherLogService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysDictionaryItemsService sysDictionaryItemsService;
|
private DeviceWorkDataMapper deviceWorkDataMapper;
|
||||||
|
|
||||||
/**********************************
|
/**********************************
|
||||||
* 用途说明: 查询环境信息
|
* 用途说明: 查询环境信息
|
||||||
@ -36,34 +37,11 @@ public class WeatherLogServiceImpl extends ServiceImpl<WeatherLogMapper, Weather
|
|||||||
***********************************/
|
***********************************/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getWeatherLogList(String stationId) {
|
public Map<String, Object> getWeatherLogList(String stationId) {
|
||||||
|
List<Map<String, Object>> deviceWorkData = deviceWorkDataMapper.getDeviceWorkData(stationId);
|
||||||
LambdaQueryWrapper<WeatherLog> queryWrapper = new LambdaQueryWrapper<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
queryWrapper.eq(WeatherLog::getStationId, stationId).eq(WeatherLog::getDatastatus, "1").orderByDesc(WeatherLog::getTime);
|
for (Map<String, Object> deviceWorkDatum : deviceWorkData) {
|
||||||
List<WeatherLog> list = this.list(queryWrapper);
|
map.put(deviceWorkDatum.get("itemcode").toString(), deviceWorkDatum.get("value"));
|
||||||
Map<String, List<WeatherLog>> collect =
|
|
||||||
list.stream().filter(s -> StrUtil.isNotBlank(s.getType())).collect(Collectors.groupingBy(WeatherLog::getType));
|
|
||||||
List<Map<String, Object>> environmentType = sysDictionaryItemsService.getDeviceByType("EnvironmentType");
|
|
||||||
Map<String, Object> weatherDevice = new HashMap<>();
|
|
||||||
for (Map<String, Object> map : environmentType) {
|
|
||||||
String itemcode = map.get("itemcode").toString();
|
|
||||||
String value = "";
|
|
||||||
for (String type : collect.keySet()) {
|
|
||||||
List<WeatherLog> weatherLogs = collect.get(type);
|
|
||||||
if (type.equals(itemcode)) {
|
|
||||||
WeatherLog weatherLog = weatherLogs.get(0);
|
|
||||||
String value1 = weatherLog.getValue();
|
|
||||||
if (StrUtil.isNotBlank(value1)) {
|
|
||||||
value = value1;
|
|
||||||
}
|
}
|
||||||
break;
|
return map;
|
||||||
}
|
|
||||||
}
|
|
||||||
String custom2 = map.get("custom2").toString();
|
|
||||||
weatherDevice.put(custom2, value);
|
|
||||||
}
|
|
||||||
String environment = "气温" + weatherDevice.get("temperature") + "°C,气压" + weatherDevice.get("pressure") + "Kpa" +
|
|
||||||
",风速" + weatherDevice.get("windSpeed") + "m/s";
|
|
||||||
weatherDevice.put("environment", environment);
|
|
||||||
return weatherDevice;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.yfd.platform.component.WebSocketServer;
|
import com.yfd.platform.component.WebSocketServer;
|
||||||
import com.yfd.platform.config.ResponseResult;
|
import com.yfd.platform.config.ResponseResult;
|
||||||
|
import com.yfd.platform.modules.auxcontrol.service.IDeviceWorkDataService;
|
||||||
import com.yfd.platform.modules.basedata.domain.DeviceChannel;
|
import com.yfd.platform.modules.basedata.domain.DeviceChannel;
|
||||||
import com.yfd.platform.modules.basedata.domain.SubstationDevice;
|
import com.yfd.platform.modules.basedata.domain.SubstationDevice;
|
||||||
import com.yfd.platform.modules.basedata.service.IDeviceChannelService;
|
import com.yfd.platform.modules.basedata.service.IDeviceChannelService;
|
||||||
@ -54,6 +55,9 @@ public class AlarmLogController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ISubstationDeviceService substationDeviceService;
|
private ISubstationDeviceService substationDeviceService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IDeviceWorkDataService deviceWorkDataService;
|
||||||
|
|
||||||
@GetMapping("/getAlarmLogList")
|
@GetMapping("/getAlarmLogList")
|
||||||
@ApiOperation("查询报警信息")
|
@ApiOperation("查询报警信息")
|
||||||
public ResponseResult getAlarmLogList(String stationId) {
|
public ResponseResult getAlarmLogList(String stationId) {
|
||||||
@ -288,10 +292,13 @@ public class AlarmLogController {
|
|||||||
@GetMapping("/createAlarmData")
|
@GetMapping("/createAlarmData")
|
||||||
@ApiOperation("生成报警")
|
@ApiOperation("生成报警")
|
||||||
public ResponseResult createAlarmData(String from,String type,String slaveIp,String address,String value) {
|
public ResponseResult createAlarmData(String from,String type,String slaveIp,String address,String value) {
|
||||||
|
deviceWorkDataService.insertData(from, type, slaveIp, address, value);
|
||||||
alarmLogService.doAlaramRecord(from, type, slaveIp, address, value);
|
alarmLogService.doAlaramRecord(from, type, slaveIp, address, value);
|
||||||
// alarmLogService.doAlaramRecord("IEC61850", "yx", "192.168.1.1", "10", "2");
|
// alarmLogService.doAlaramRecord("IEC61850", "yx", "192.168.1.1", "10", "2");
|
||||||
|
|
||||||
return ResponseResult.success();
|
return ResponseResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2204,19 +2204,12 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
|||||||
if ("1".equals(value)) {
|
if ("1".equals(value)) {
|
||||||
//填充告警记录信息接口
|
//填充告警记录信息接口
|
||||||
AlarmLog alarmLog = FillingDeviceAlarmRecord(type, null, map, value);
|
AlarmLog alarmLog = FillingDeviceAlarmRecord(type, null, map, value);
|
||||||
//首先判断 在不在时间范围之内 判断时间在不在时间范围之内接口
|
|
||||||
Map<String, Object> timeInterval = getTimeInterval(7);
|
|
||||||
//查询表中是否存在该报警记录
|
|
||||||
List<AlarmLog> alarmRecords = queryDeviceAlarmRecord(alarmLog, timeInterval);
|
|
||||||
//如果没有有报警记录 新增记录
|
|
||||||
if (alarmRecords.size() == 0) {
|
|
||||||
doAlarmAction(alarmLog);
|
doAlarmAction(alarmLog);
|
||||||
} else if (alarmRecords.size() > 1) {
|
WebSocketServer.sendInfo(alarmLog.getStationId(), JSONUtil.parseObj(alarmLog).toString());
|
||||||
this.removeById(alarmRecords.get(0).getId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ("yc".equals(type)) {
|
if ("yc".equals(type)) {
|
||||||
//1.通过设备id 和信号id 查询告警参数设置表(告警规则)
|
//1.通过设备id 和信号id 查询告警参数设置表(告警规则)
|
||||||
LambdaQueryWrapper<DeviceAlarmParameter> querywrapperdap = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DeviceAlarmParameter> querywrapperdap = new LambdaQueryWrapper<>();
|
||||||
if (StrUtil.isNotEmpty(map.get("meterDeviceId").toString())) {
|
if (StrUtil.isNotEmpty(map.get("meterDeviceId").toString())) {
|
||||||
@ -2232,28 +2225,20 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
|||||||
if (deviceAlarmParameter.getAlarmCondition() != null) {
|
if (deviceAlarmParameter.getAlarmCondition() != null) {
|
||||||
//根据告警规则 判断是否触发告警
|
//根据告警规则 判断是否触发告警
|
||||||
boolean alarmTrigger = TriggerAlarm(deviceAlarmParameter, value);
|
boolean alarmTrigger = TriggerAlarm(deviceAlarmParameter, value);
|
||||||
|
|
||||||
//2.通过告警触发条件 和 value比较 满足条件 触发告警
|
//2.通过告警触发条件 和 value比较 满足条件 触发告警
|
||||||
if (alarmTrigger) {
|
if (alarmTrigger) {
|
||||||
AlarmLog alarmLog = FillingDeviceAlarmRecord(type, deviceAlarmParameter
|
AlarmLog alarmLog = FillingDeviceAlarmRecord(type, deviceAlarmParameter
|
||||||
, map, value);
|
, map, value);
|
||||||
//首先判断 在不在时间范围之内 判断时间在不在时间范围之内接口
|
|
||||||
Map<String, Object> timeInterval = getTimeInterval(7);
|
|
||||||
//如果在时间范围内
|
|
||||||
//查询表中是否存在该报警记录
|
|
||||||
List<AlarmLog> alarmRecords = queryDeviceAlarmRecord(alarmLog,
|
|
||||||
timeInterval);
|
|
||||||
//如果没有有报警记录 新增记录
|
|
||||||
if (alarmRecords.size() == 0) {
|
|
||||||
// 新增
|
// 新增
|
||||||
alarmLogMapper.insert(alarmLog);
|
alarmLogMapper.insert(alarmLog);
|
||||||
//TODO 邮件推送暂时删除了
|
//TODO 邮件推送暂时删除了
|
||||||
|
WebSocketServer.sendInfo(alarmLog.getStationId(), JSONUtil.parseObj(alarmLog).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
log.info("-----------------------------告警创建完毕------------------------------------");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,4 +38,40 @@
|
|||||||
ORDER BY
|
ORDER BY
|
||||||
start_time DESC
|
start_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getDeviceWorkData" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
di.*,-- 保留第一个子查询的所有字段
|
||||||
|
COALESCE ( sub.yc_value, '无' ) AS value
|
||||||
|
,-- 将 NULL 转为 "无"
|
||||||
|
di.unit,
|
||||||
|
sub.signalId AS sub_signalId,-- 可选:重命名避免字段冲突
|
||||||
|
sub.ip AS sub_ip
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
*,
|
||||||
|
JSON_UNQUOTE(
|
||||||
|
JSON_EXTRACT( custom1, '$.signalId' )) AS signalId,
|
||||||
|
JSON_UNQUOTE(
|
||||||
|
JSON_EXTRACT( custom1, '$.unit' )) AS unit,
|
||||||
|
JSON_UNQUOTE(
|
||||||
|
JSON_EXTRACT( custom1, '$.ip' )) AS ip -- 确保提取的是 ip 字段
|
||||||
|
|
||||||
|
FROM
|
||||||
|
sys_dictionary_items
|
||||||
|
WHERE
|
||||||
|
dictid = 'ca593d0a2a60f7ef37c89e615b97024b'
|
||||||
|
) di
|
||||||
|
LEFT JOIN (-- 使用 LEFT JOIN 保留 di 的所有记录
|
||||||
|
SELECT
|
||||||
|
b.yc_value,
|
||||||
|
b.signal_id AS signalId,
|
||||||
|
c.ip_addr AS ip
|
||||||
|
FROM
|
||||||
|
fk_meter_device a
|
||||||
|
INNER JOIN fk_device_signal b ON a.device_id = b.meter_device_id
|
||||||
|
INNER JOIN fk_gateway_device c ON a.netdevice_ip = c.ip_addr
|
||||||
|
) sub ON di.signalId = sub.signalId
|
||||||
|
AND di.ip = sub.ip ORDER BY orderno;
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user