新增查询部件信号树
This commit is contained in:
parent
e15c672760
commit
621b252d6a
@ -18,4 +18,6 @@ public interface DeviceSignalMapper extends BaseMapper<DeviceSignal> {
|
||||
|
||||
DeviceSignal selectOneDeviceSignal(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);
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import com.yfd.platform.modules.auxcontrol.domain.DeviceSignal;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -50,4 +52,6 @@ public interface IDeviceSignalService extends IService<DeviceSignal> {
|
||||
* 返回值说明: com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.yfd.platform.modules.auxcontrol.domain.DeviceSignal>
|
||||
***********************************/
|
||||
Page<DeviceSignal> getDeviceSignalPage(String deviceId, String signalName, Page<DeviceSignal> page);
|
||||
|
||||
List<Map<String, Object>> getDeviceSignalMaps(String mainDeviceId, String signalName);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -126,4 +127,9 @@ public class DeviceSignalServiceImpl extends ServiceImpl<DeviceSignalMapper, Dev
|
||||
return deviceSignalMapper.selectPage(page, queryWrapper);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getDeviceSignalMaps(String mainDeviceId, String signalName) {
|
||||
return deviceSignalMapper.getDeviceSignalMaps(mainDeviceId, signalName);
|
||||
}
|
||||
}
|
||||
|
@ -459,4 +459,11 @@ public class SubstationMaindeviceController {
|
||||
TreeNode treeNode = substationMaindeviceService.getSubstationMainTree(stationCode, mainDeviceName);
|
||||
return ResponseResult.successData(treeNode);
|
||||
}
|
||||
|
||||
@GetMapping("/getDeviceSignalTree")
|
||||
@ApiOperation("获取信号树(前台)")
|
||||
public ResponseResult getDeviceSignalTree(String mainDeviceId,String signalName) {
|
||||
List<TreeNode> treeNodes = substationMaindeviceService.getDeviceSignalTree(mainDeviceId,signalName);
|
||||
return ResponseResult.successData(treeNodes);
|
||||
}
|
||||
}
|
||||
|
@ -123,4 +123,6 @@ public interface ISubstationMaindeviceService extends IService<SubstationMaindev
|
||||
List<Map<String, Object>> getSubstationMainDeviceTree(String stationCode,String mainDeviceName);
|
||||
|
||||
TreeNode getSubstationMainTree(String stationCode, String mainDeviceName);
|
||||
|
||||
List<TreeNode> getDeviceSignalTree(String mainDeviceId,String signalName);
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package com.yfd.platform.modules.basedata.service.impl;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yfd.platform.modules.auxcontrol.domain.DeviceSignal;
|
||||
import com.yfd.platform.modules.auxcontrol.service.IDeviceSignalService;
|
||||
import com.yfd.platform.modules.basedata.domain.*;
|
||||
import com.yfd.platform.modules.basedata.mapper.*;
|
||||
import com.yfd.platform.modules.basedata.service.ISubstationMaindeviceService;
|
||||
@ -61,6 +63,9 @@ public class SubstationMaindeviceServiceImpl extends ServiceImpl<SubstationMaind
|
||||
@Resource
|
||||
private ISysDictionaryItemsService sysDictionaryItemsService;
|
||||
|
||||
@Resource
|
||||
private IDeviceSignalService deviceSignalService;
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 获取主设备及部件树
|
||||
* 参数说明 name 参数名称
|
||||
@ -667,13 +672,69 @@ public class SubstationMaindeviceServiceImpl extends ServiceImpl<SubstationMaind
|
||||
queryWrapper.select(SubstationMaindevice::getStationCode,
|
||||
SubstationMaindevice::getStationName, SubstationMaindevice::getStationName,
|
||||
SubstationMaindevice::getAreaId,
|
||||
SubstationMaindevice::getAreaName, SubstationMaindevice::getBayId, SubstationMaindevice::getBayName, SubstationMaindevice::getMainDeviceId, SubstationMaindevice::getMainDeviceName);
|
||||
SubstationMaindevice::getAreaName, SubstationMaindevice::getBayId, SubstationMaindevice::getBayName,
|
||||
SubstationMaindevice::getMainDeviceId, SubstationMaindevice::getMainDeviceName);
|
||||
List<Map<String, Object>> list = this.listMaps(queryWrapper);
|
||||
List<Map<String, Object>> mapList = list.stream().distinct().collect(Collectors.toList());
|
||||
List<TreeNode> treeNodes = this.buildTree(mapList);
|
||||
return treeNodes.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeNode> getDeviceSignalTree(String mainDeviceId, String signalName) {
|
||||
List<Map<String, Object>> dataList = deviceSignalService.getDeviceSignalMaps(mainDeviceId, signalName);
|
||||
List<TreeNode> treeNodes = this.buildSignalTree(dataList);
|
||||
if (treeNodes.size() <= 0) {
|
||||
return treeNodes;
|
||||
}
|
||||
return treeNodes.get(0).getChildren();
|
||||
}
|
||||
|
||||
public List<TreeNode> buildSignalTree(List<Map<String, Object>> dataList) {
|
||||
// 存储所有节点(使用ID作为键)
|
||||
Map<String, TreeNode> nodeMap = new HashMap<>();
|
||||
// 存储最终返回的根节点列表
|
||||
List<TreeNode> roots = new ArrayList<>();
|
||||
// 遍历原始数据
|
||||
for (Map<String, Object> data : dataList) {
|
||||
// 1. 解析各层级信息(根据实际字段名称调整)
|
||||
String mainDeviceId = (String) data.get("mainDeviceId");
|
||||
String mainDeviceName = (String) data.get("mainDeviceName");
|
||||
String componentId = (String) data.get("componentId");
|
||||
String componentName = (String) data.get("componentName");
|
||||
String signalId = (String) data.get("signalId");
|
||||
String signalName = (String) data.get("signalName");
|
||||
|
||||
// 处理变电站层级
|
||||
TreeNode mainDeviceNode = nodeMap.computeIfAbsent(mainDeviceId,
|
||||
k -> {
|
||||
TreeNode node = new TreeNode(mainDeviceId, mainDeviceName);
|
||||
roots.add(node); // 将变电站作为根节点
|
||||
return node;
|
||||
});
|
||||
|
||||
if (StrUtil.isNotBlank(componentId)) {
|
||||
TreeNode componentNode = nodeMap.computeIfAbsent(componentId,
|
||||
k -> {
|
||||
TreeNode node = new TreeNode(componentId, componentName);
|
||||
mainDeviceNode.getChildren().add(node);
|
||||
return node;
|
||||
});
|
||||
|
||||
// 处理间隔层级
|
||||
if (StrUtil.isNotBlank(signalId)) {
|
||||
TreeNode signalNode = nodeMap.computeIfAbsent(signalId,
|
||||
k -> {
|
||||
TreeNode node = new TreeNode(signalId, signalName);
|
||||
componentNode.getChildren().add(node);
|
||||
return node;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return roots;
|
||||
}
|
||||
|
||||
public List<TreeNode> buildTree(List<Map<String, Object>> dataList) {
|
||||
// 存储所有节点(使用ID作为键)
|
||||
|
@ -37,7 +37,7 @@
|
||||
JOIN fk_gateway_device c ON ( a.netdevice_ip = c.ip_addr )
|
||||
WHERE
|
||||
<if test="slaveIp != null and slaveIp != ''">
|
||||
c.ip_addr = #{slaveIp}
|
||||
c.ip_addr = #{slaveIp}
|
||||
</if>
|
||||
<if test="type=='yx'">
|
||||
and b.yx_addr = #{address}
|
||||
@ -47,5 +47,26 @@
|
||||
</if>
|
||||
limit 1
|
||||
</select>
|
||||
<select id="getDeviceSignalMaps" resultType="java.util.Map">
|
||||
SELECT
|
||||
fds.signal_id,
|
||||
fds.signal_code,
|
||||
fds.signal_name,
|
||||
isc.main_device_id,
|
||||
isc.main_device_name,
|
||||
isc.component_id,
|
||||
isc.component_name
|
||||
FROM
|
||||
fk_device_signal fds
|
||||
INNER JOIN iis_substation_component isc ON isc.component_id = fds.main_compnent_id
|
||||
WHERE 1=1
|
||||
<if test="mainDeviceId != null and mainDeviceId != ''">
|
||||
AND fds.main_device_id = #{mainDeviceId}
|
||||
</if>
|
||||
|
||||
<if test="signalName != null and signalName != ''">
|
||||
fds.signal_name LIKE CONCAT('',#{signalName},'')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user