优化设备检测模块功能
This commit is contained in:
parent
fa6f7d7a8b
commit
0f5d46341a
@ -1,5 +1,6 @@
|
|||||||
package com.yfd.platform.modules.auxcontrol.controller;
|
package com.yfd.platform.modules.auxcontrol.controller;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.yfd.platform.config.ResponseResult;
|
import com.yfd.platform.config.ResponseResult;
|
||||||
import com.yfd.platform.modules.auxcontrol.domain.DeviceAlarmRecord;
|
import com.yfd.platform.modules.auxcontrol.domain.DeviceAlarmRecord;
|
||||||
@ -12,6 +13,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.LongStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -31,9 +41,54 @@ public class DeviceWorkDataController {
|
|||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@ApiOperation("分页查询变电站辅控设备告警记录")
|
@ApiOperation("分页查询变电站辅控设备告警记录")
|
||||||
public ResponseResult getDeviceWorkDataPage(Page<DeviceWorkData> page, String startDate, String endDate) {
|
public ResponseResult getDeviceWorkDataPage(Page<DeviceWorkData> page, String stationId, String startDate,
|
||||||
Page<DeviceWorkData> deviceWorkDataPage = deviceWorkDataService.getDeviceWorkDataPage(page, startDate, endDate);
|
String endDate) {
|
||||||
|
Page<DeviceWorkData> deviceWorkDataPage = deviceWorkDataService.getDeviceWorkDataPage(page, stationId,
|
||||||
|
startDate, endDate);
|
||||||
return ResponseResult.successData(deviceWorkDataPage);
|
return ResponseResult.successData(deviceWorkDataPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<DeviceWorkData> processMinuteDataOptimized(List<DeviceWorkData> deviceWorkDataList) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getHistoricalCurve")
|
||||||
|
@ApiOperation("查询历史曲线")
|
||||||
|
public ResponseResult getHistoricalCurve(String stationId, String type) {
|
||||||
|
List<DeviceWorkData> deviceWorkDataList = deviceWorkDataService.getHistoricalCurve(stationId);
|
||||||
|
|
||||||
|
Map<String, Object> historicalCurve = new HashMap<>();
|
||||||
|
historicalCurve.put("xAxis", JSONUtil.parseObj("{\n" +
|
||||||
|
" type: 'category',\n" +
|
||||||
|
" data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']\n" +
|
||||||
|
" }"));
|
||||||
|
|
||||||
|
historicalCurve.put("yAxis", JSONUtil.parseObj("{\n" +
|
||||||
|
" type: 'value'\n" +
|
||||||
|
" }"));
|
||||||
|
|
||||||
|
historicalCurve.put("series", JSONUtil.parseArray("[\n" +
|
||||||
|
" {\n" +
|
||||||
|
" name: 'Step Start',\n" +
|
||||||
|
" type: 'line',\n" +
|
||||||
|
" step: 'start',\n" +
|
||||||
|
" data: [120, 132, 101, 134, 90, 230, 210]\n" +
|
||||||
|
" },\n" +
|
||||||
|
" {\n" +
|
||||||
|
" name: 'Step Middle',\n" +
|
||||||
|
" type: 'line',\n" +
|
||||||
|
" step: 'middle',\n" +
|
||||||
|
" data: [220, 282, 201, 234, 290, 430, 410]\n" +
|
||||||
|
" },\n" +
|
||||||
|
" {\n" +
|
||||||
|
" name: 'Step End',\n" +
|
||||||
|
" type: 'line',\n" +
|
||||||
|
" step: 'end',\n" +
|
||||||
|
" data: [450, 432, 401, 454, 590, 530, 510]\n" +
|
||||||
|
" }\n" +
|
||||||
|
" ]"));
|
||||||
|
|
||||||
|
return ResponseResult.successData(historicalCurve);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public interface DeviceSignalMapper extends BaseMapper<DeviceSignal> {
|
|||||||
|
|
||||||
DeviceSignal selectOneDeviceSignal(String slaveIp, String type, String address);
|
DeviceSignal selectOneDeviceSignal(String slaveIp, String type, String address);
|
||||||
Map<String,Object> selectDeviceSignalMap(String slaveIp, String type, String address);
|
Map<String,Object> selectDeviceSignalMap(String slaveIp, String type, String address);
|
||||||
List<Map<String, Object>> getDeviceSignalMaps(String mainDeviceId, String signalName);
|
List<Map<String, Object>> getDeviceSignalMaps(String stationCode, String signalName);
|
||||||
|
|
||||||
List<DeviceSignal> selectDeviceSignalByIp(String ip);
|
List<DeviceSignal> selectDeviceSignalByIp(String ip);
|
||||||
@Update("UPDATE fk_device_signal SET yc_value = #{value}, lastmodifydate = #{datetime} WHERE yc_addr = #{node_addr}")
|
@Update("UPDATE fk_device_signal SET yc_value = #{value}, lastmodifydate = #{datetime} WHERE yc_addr = #{node_addr}")
|
||||||
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.yfd.platform.modules.auxcontrol.domain.DeviceWorkData;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 变电站-设备-运行数据 Mapper 接口
|
* 变电站-设备-运行数据 Mapper 接口
|
||||||
@ -14,5 +16,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
*/
|
*/
|
||||||
public interface DeviceWorkDataMapper extends BaseMapper<DeviceWorkData> {
|
public interface DeviceWorkDataMapper extends BaseMapper<DeviceWorkData> {
|
||||||
|
|
||||||
Page<DeviceWorkData> getDeviceWorkDataPage(Page<DeviceWorkData> page, String startDate, String endDate);
|
Page<DeviceWorkData> getDeviceWorkDataPage(Page<DeviceWorkData> page,String stationId, String startDate, String endDate);
|
||||||
|
|
||||||
|
List<DeviceWorkData> getHistoricalCurve(String stationId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public interface IDeviceSignalService extends IService<DeviceSignal> {
|
|||||||
***********************************/
|
***********************************/
|
||||||
Page<DeviceSignal> getDeviceSignalPage(String deviceId, String signalName, Page<DeviceSignal> page);
|
Page<DeviceSignal> getDeviceSignalPage(String deviceId, String signalName, Page<DeviceSignal> page);
|
||||||
|
|
||||||
List<Map<String, Object>> getDeviceSignalMaps(String mainDeviceId, String signalName);
|
List<Map<String, Object>> getDeviceSignalMaps(String stationCode, String signalName);
|
||||||
|
|
||||||
Map<String, Object> querySignalDataById(String signalId);
|
Map<String, Object> querySignalDataById(String signalId);
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.yfd.platform.modules.auxcontrol.domain.DeviceWorkData;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 变电站-设备-运行数据 服务类
|
* 变电站-设备-运行数据 服务类
|
||||||
@ -26,6 +28,8 @@ public interface IDeviceWorkDataService extends IService<DeviceWorkData> {
|
|||||||
***********************************/
|
***********************************/
|
||||||
void insertData(String from, String slave_ip, String address, String value, String dateTimeString);
|
void insertData(String from, String slave_ip, String address, String value, String dateTimeString);
|
||||||
|
|
||||||
Page<DeviceWorkData> getDeviceWorkDataPage(Page<DeviceWorkData> page, String startDate, String endDate);
|
Page<DeviceWorkData> getDeviceWorkDataPage(Page<DeviceWorkData> page,String stationId, String startDate, String endDate);
|
||||||
|
|
||||||
|
List<DeviceWorkData> getHistoricalCurve(String stationId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,8 +129,8 @@ public class DeviceSignalServiceImpl extends ServiceImpl<DeviceSignalMapper, Dev
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> getDeviceSignalMaps(String mainDeviceId, String signalName) {
|
public List<Map<String, Object>> getDeviceSignalMaps(String stationCode, String signalName) {
|
||||||
return deviceSignalMapper.getDeviceSignalMaps(mainDeviceId, signalName);
|
return deviceSignalMapper.getDeviceSignalMaps(stationCode, signalName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,8 +72,13 @@ public class DeviceWorkDataServiceImpl extends ServiceImpl<DeviceWorkDataMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DeviceWorkData> getDeviceWorkDataPage(Page<DeviceWorkData> page, String startDate, String endDate) {
|
public Page<DeviceWorkData> getDeviceWorkDataPage(Page<DeviceWorkData> page,String stationId, String startDate, String endDate) {
|
||||||
return deviceWorkDataMapper.getDeviceWorkDataPage(page,startDate,endDate);
|
return deviceWorkDataMapper.getDeviceWorkDataPage(page,stationId,startDate,endDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceWorkData> getHistoricalCurve(String stationId) {
|
||||||
|
return deviceWorkDataMapper.getHistoricalCurve(stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -462,8 +462,8 @@ public class SubstationMaindeviceController {
|
|||||||
|
|
||||||
@GetMapping("/getDeviceSignalTree")
|
@GetMapping("/getDeviceSignalTree")
|
||||||
@ApiOperation("获取信号树(前台)")
|
@ApiOperation("获取信号树(前台)")
|
||||||
public ResponseResult getDeviceSignalTree(String mainDeviceId,String signalName) {
|
public ResponseResult getDeviceSignalTree(String stationCode,String signalName) {
|
||||||
List<TreeNode> treeNodes = substationMaindeviceService.getDeviceSignalTree(mainDeviceId,signalName);
|
List<TreeNode> treeNodes = substationMaindeviceService.getDeviceSignalTree(stationCode,signalName);
|
||||||
return ResponseResult.successData(treeNodes);
|
return ResponseResult.successData(treeNodes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,5 +124,5 @@ public interface ISubstationMaindeviceService extends IService<SubstationMaindev
|
|||||||
|
|
||||||
TreeNode getSubstationMainTree(String stationCode, String mainDeviceName);
|
TreeNode getSubstationMainTree(String stationCode, String mainDeviceName);
|
||||||
|
|
||||||
List<TreeNode> getDeviceSignalTree(String mainDeviceId,String signalName);
|
List<TreeNode> getDeviceSignalTree(String stationCode,String signalName);
|
||||||
}
|
}
|
||||||
|
@ -681,8 +681,8 @@ public class SubstationMaindeviceServiceImpl extends ServiceImpl<SubstationMaind
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TreeNode> getDeviceSignalTree(String mainDeviceId, String signalName) {
|
public List<TreeNode> getDeviceSignalTree(String stationCode, String signalName) {
|
||||||
List<Map<String, Object>> dataList = deviceSignalService.getDeviceSignalMaps(mainDeviceId, signalName);
|
List<Map<String, Object>> dataList = deviceSignalService.getDeviceSignalMaps(stationCode, signalName);
|
||||||
List<TreeNode> treeNodes = this.buildSignalTree(dataList);
|
List<TreeNode> treeNodes = this.buildSignalTree(dataList);
|
||||||
if (treeNodes.size() <= 0) {
|
if (treeNodes.size() <= 0) {
|
||||||
return treeNodes;
|
return treeNodes;
|
||||||
@ -698,6 +698,12 @@ public class SubstationMaindeviceServiceImpl extends ServiceImpl<SubstationMaind
|
|||||||
// 遍历原始数据
|
// 遍历原始数据
|
||||||
for (Map<String, Object> data : dataList) {
|
for (Map<String, Object> data : dataList) {
|
||||||
// 1. 解析各层级信息(根据实际字段名称调整)
|
// 1. 解析各层级信息(根据实际字段名称调整)
|
||||||
|
String stationCode = (String) data.get("stationCode");
|
||||||
|
String stationName = (String) data.get("stationName");
|
||||||
|
String areaId = (String) data.get("areaId");
|
||||||
|
String areaName = (String) data.get("areaName");
|
||||||
|
String bayId = (String) data.get("bayId");
|
||||||
|
String bayName = (String) data.get("bayName");
|
||||||
String mainDeviceId = (String) data.get("mainDeviceId");
|
String mainDeviceId = (String) data.get("mainDeviceId");
|
||||||
String mainDeviceName = (String) data.get("mainDeviceName");
|
String mainDeviceName = (String) data.get("mainDeviceName");
|
||||||
String componentId = (String) data.get("componentId");
|
String componentId = (String) data.get("componentId");
|
||||||
@ -705,14 +711,40 @@ public class SubstationMaindeviceServiceImpl extends ServiceImpl<SubstationMaind
|
|||||||
String signalId = (String) data.get("signalId");
|
String signalId = (String) data.get("signalId");
|
||||||
String signalName = (String) data.get("signalName");
|
String signalName = (String) data.get("signalName");
|
||||||
|
|
||||||
// 处理变电站层级
|
TreeNode stationNode = nodeMap.computeIfAbsent(stationCode,
|
||||||
TreeNode mainDeviceNode = nodeMap.computeIfAbsent(mainDeviceId,
|
|
||||||
k -> {
|
k -> {
|
||||||
TreeNode node = new TreeNode(mainDeviceId, mainDeviceName);
|
TreeNode node = new TreeNode(stationCode, stationName);
|
||||||
roots.add(node); // 将变电站作为根节点
|
roots.add(node); // 将变电站作为根节点
|
||||||
return node;
|
return node;
|
||||||
});
|
});
|
||||||
|
if (StrUtil.isNotBlank(areaId)) {
|
||||||
|
// 处理变电站层级
|
||||||
|
TreeNode areaNode = nodeMap.computeIfAbsent(areaId,
|
||||||
|
k -> {
|
||||||
|
TreeNode node = new TreeNode(areaId, areaName);
|
||||||
|
stationNode.getChildren().add(node); // 将变电站作为根节点
|
||||||
|
return node;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 处理区域层级
|
||||||
|
if (StrUtil.isNotBlank(bayId)) {
|
||||||
|
TreeNode bayNode = nodeMap.computeIfAbsent(bayId,
|
||||||
|
k -> {
|
||||||
|
TreeNode node = new TreeNode(bayId, bayName);
|
||||||
|
areaNode.getChildren().add(node);
|
||||||
|
return node;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 处理间隔层级
|
||||||
|
if (StrUtil.isNotBlank(mainDeviceId)) {
|
||||||
|
TreeNode mainDeviceNode = nodeMap.computeIfAbsent(mainDeviceId,
|
||||||
|
k -> {
|
||||||
|
TreeNode node = new TreeNode(mainDeviceId, mainDeviceName);
|
||||||
|
bayNode.getChildren().add(node);
|
||||||
|
return node;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 处理主设备层级
|
||||||
if (StrUtil.isNotBlank(componentId)) {
|
if (StrUtil.isNotBlank(componentId)) {
|
||||||
TreeNode componentNode = nodeMap.computeIfAbsent(componentId,
|
TreeNode componentNode = nodeMap.computeIfAbsent(componentId,
|
||||||
k -> {
|
k -> {
|
||||||
@ -720,19 +752,21 @@ public class SubstationMaindeviceServiceImpl extends ServiceImpl<SubstationMaind
|
|||||||
mainDeviceNode.getChildren().add(node);
|
mainDeviceNode.getChildren().add(node);
|
||||||
return node;
|
return node;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 处理间隔层级
|
|
||||||
if (StrUtil.isNotBlank(signalId)) {
|
if (StrUtil.isNotBlank(signalId)) {
|
||||||
TreeNode signalNode = nodeMap.computeIfAbsent(signalId,
|
nodeMap.computeIfAbsent(signalId,
|
||||||
k -> {
|
k -> {
|
||||||
TreeNode node = new TreeNode(signalId, signalName);
|
TreeNode node = new TreeNode(signalId, signalName);
|
||||||
componentNode.getChildren().add(node);
|
componentNode.getChildren().add(node);
|
||||||
return node;
|
return node;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return roots;
|
return roots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,13 +55,18 @@
|
|||||||
isc.main_device_id,
|
isc.main_device_id,
|
||||||
isc.main_device_name,
|
isc.main_device_name,
|
||||||
isc.component_id,
|
isc.component_id,
|
||||||
isc.component_name
|
isc.component_name,
|
||||||
|
isc.station_code,
|
||||||
|
isc.area_id,
|
||||||
|
isc.area_name,
|
||||||
|
isc.bay_id,
|
||||||
|
isc.bay_name
|
||||||
FROM
|
FROM
|
||||||
fk_device_signal fds
|
fk_device_signal fds
|
||||||
INNER JOIN iis_substation_component isc ON isc.component_id = fds.main_compnent_id
|
INNER JOIN iis_substation_component isc ON isc.component_id = fds.main_compnent_id
|
||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
<if test="mainDeviceId != null and mainDeviceId != ''">
|
<if test="stationCode != null and stationCode != ''">
|
||||||
AND fds.main_device_id = #{mainDeviceId}
|
AND isc.station_code = #{stationCode}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="signalName != null and signalName != ''">
|
<if test="signalName != null and signalName != ''">
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
FROM
|
FROM
|
||||||
fk_device_work_data
|
fk_device_work_data
|
||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
|
AND station_id=#{stationId}
|
||||||
<if test="startDate != null and startDate != ''">
|
<if test="startDate != null and startDate != ''">
|
||||||
AND start_time >= #{startDate}
|
AND start_time >= #{startDate}
|
||||||
</if>
|
</if>
|
||||||
@ -24,4 +25,17 @@
|
|||||||
ORDER BY start_time DESC
|
ORDER BY start_time DESC
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getHistoricalCurve" resultType="com.yfd.platform.modules.auxcontrol.domain.DeviceWorkData">
|
||||||
|
SELECT
|
||||||
|
start_time,
|
||||||
|
`value`,
|
||||||
|
unit
|
||||||
|
FROM
|
||||||
|
fk_device_work_data
|
||||||
|
WHERE
|
||||||
|
station_id=#{stationId}
|
||||||
|
AND start_time >= NOW() - INTERVAL 1 HOUR
|
||||||
|
ORDER BY
|
||||||
|
start_time DESC
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user