优化算法和故障诊断逻辑
This commit is contained in:
parent
44576b6147
commit
05ab1e9d4d
@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.yfd.platform.config.ResponseResult;
|
import com.yfd.platform.config.ResponseResult;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmParamsRequest;
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmParamsRequest;
|
||||||
|
import com.yfd.platform.modules.algorithm.domain.TreeNode;
|
||||||
import com.yfd.platform.modules.algorithm.service.IAlgorithmClassService;
|
import com.yfd.platform.modules.algorithm.service.IAlgorithmClassService;
|
||||||
import com.yfd.platform.modules.basedata.domain.TreeNode;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -41,4 +42,20 @@ public class AlgorithmDeviceController {
|
|||||||
return ResponseResult.error();
|
return ResponseResult.error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getAlgorithmDeviceParams")
|
||||||
|
@ApiOperation("查询算法部件的参数")
|
||||||
|
public ResponseResult getAlgorithmDeviceParams(String algorithmId, String componentId) {
|
||||||
|
List<Map<String, Object>> algorithmDeviceParams = algorithmDeviceService.getAlgorithmDeviceParams(algorithmId
|
||||||
|
, componentId);
|
||||||
|
return ResponseResult.successData(algorithmDeviceParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @PostMapping("/getAlgorithmDeviceParams")
|
||||||
|
// @ApiOperation("查询算法部件的参数")
|
||||||
|
// public ResponseResult getAlgorithmDeviceParams(String algorithmId, String componentId) {
|
||||||
|
// List<Map<String, Object>> algorithmDeviceParams = algorithmDeviceService.getAlgorithmDeviceParams(algorithmId
|
||||||
|
// , componentId);
|
||||||
|
// return ResponseResult.successData(algorithmDeviceParams);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.yfd.platform.modules.algorithm.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Date: 2024/4/18 15:10
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class TreeNode {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private String parentId;
|
||||||
|
private List<TreeNode> children = new ArrayList<>();
|
||||||
|
|
||||||
|
public TreeNode(String id, String name, String parentId) {
|
||||||
|
this.id = id;
|
||||||
|
this.parentId = parentId;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@ package com.yfd.platform.modules.algorithm.service;
|
|||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmParamsRequest;
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmParamsRequest;
|
||||||
import com.yfd.platform.modules.basedata.domain.TreeNode;
|
import com.yfd.platform.modules.algorithm.domain.TreeNode;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.yfd.platform.modules.algorithm.domain.AlgorithmDevice;
|
|||||||
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>
|
||||||
@ -22,4 +23,6 @@ public interface IAlgorithmDeviceService extends IService<AlgorithmDevice> {
|
|||||||
***********************************/
|
***********************************/
|
||||||
boolean batchAddAlgorithmDevice(List<AlgorithmDevice> algorithmDeviceList);
|
boolean batchAddAlgorithmDevice(List<AlgorithmDevice> algorithmDeviceList);
|
||||||
|
|
||||||
|
List<Map<String, Object>> getAlgorithmDeviceParams(String algorithmId, String componentId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,18 +4,15 @@ import cn.hutool.core.util.IdUtil;
|
|||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
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.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmParams;
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmParams;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmParamsRequest;
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmParamsRequest;
|
||||||
|
import com.yfd.platform.modules.algorithm.domain.TreeNode;
|
||||||
import com.yfd.platform.modules.algorithm.mapper.AlgorithmClassComponentMapper;
|
import com.yfd.platform.modules.algorithm.mapper.AlgorithmClassComponentMapper;
|
||||||
import com.yfd.platform.modules.algorithm.mapper.AlgorithmClassMapper;
|
import com.yfd.platform.modules.algorithm.mapper.AlgorithmClassMapper;
|
||||||
import com.yfd.platform.modules.algorithm.mapper.AlgorithmParamsMapper;
|
|
||||||
import com.yfd.platform.modules.algorithm.service.IAlgorithmClassService;
|
import com.yfd.platform.modules.algorithm.service.IAlgorithmClassService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.yfd.platform.modules.algorithm.service.IAlgorithmParamsService;
|
import com.yfd.platform.modules.algorithm.service.IAlgorithmParamsService;
|
||||||
import com.yfd.platform.modules.basedata.domain.TreeNode;
|
|
||||||
import com.yfd.platform.utils.SecurityUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -132,13 +129,11 @@ public class AlgorithmClassServiceImpl extends ServiceImpl<AlgorithmClassMapper,
|
|||||||
* 返回值说明: java.util.List<com.yfd.platform.modules.basedata.domain.TreeNode>
|
* 返回值说明: java.util.List<com.yfd.platform.modules.basedata.domain.TreeNode>
|
||||||
***********************************/
|
***********************************/
|
||||||
public List<TreeNode> buildSignalTree(List<Map<String, Object>> dataList) {
|
public List<TreeNode> buildSignalTree(List<Map<String, Object>> dataList) {
|
||||||
// 存储所有节点(使用ID作为键)
|
|
||||||
Map<String, TreeNode> nodeMap = new HashMap<>();
|
Map<String, TreeNode> nodeMap = new HashMap<>();
|
||||||
// 存储最终返回的根节点列表
|
|
||||||
List<TreeNode> roots = new ArrayList<>();
|
List<TreeNode> roots = new ArrayList<>();
|
||||||
// 遍历原始数据
|
|
||||||
for (Map<String, Object> data : dataList) {
|
for (Map<String, Object> data : dataList) {
|
||||||
// 1. 解析各层级信息(根据实际字段名称调整)
|
// 解析字段(根据实际字段名称调整)
|
||||||
String stationCode = (String) data.get("stationCode");
|
String stationCode = (String) data.get("stationCode");
|
||||||
String stationName = (String) data.get("stationName");
|
String stationName = (String) data.get("stationName");
|
||||||
String algorithmId = (String) data.get("algorithmId");
|
String algorithmId = (String) data.get("algorithmId");
|
||||||
@ -146,33 +141,34 @@ public class AlgorithmClassServiceImpl extends ServiceImpl<AlgorithmClassMapper,
|
|||||||
String componentId = (String) data.get("componentId");
|
String componentId = (String) data.get("componentId");
|
||||||
String componentName = (String) data.get("componentName");
|
String componentName = (String) data.get("componentName");
|
||||||
|
|
||||||
TreeNode stationNode = nodeMap.computeIfAbsent(stationCode,
|
// 1. 处理变电站节点(根节点)
|
||||||
k -> {
|
TreeNode stationNode = nodeMap.computeIfAbsent(stationCode, k -> {
|
||||||
TreeNode node = new TreeNode(stationCode, stationName);
|
TreeNode node = new TreeNode(stationCode, stationName,null);
|
||||||
roots.add(node); // 将变电站作为根节点
|
roots.add(node); // 添加为根节点
|
||||||
|
return node;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(algorithmId)) {
|
||||||
|
// 2. 处理算法节点(第二层)
|
||||||
|
// 使用复合键:stationKey + ":" + algorithmId 确保唯一性
|
||||||
|
String algorithmKey = stationCode + ":" + algorithmId;
|
||||||
|
TreeNode algorithmNode = nodeMap.computeIfAbsent(algorithmKey, k -> {
|
||||||
|
TreeNode node = new TreeNode(algorithmId, algorithmClassName,stationCode);
|
||||||
|
stationNode.getChildren().add(node); // 挂载到变电站节点下
|
||||||
|
return node;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(componentId)) {
|
||||||
|
// 3. 处理组件节点(第三层)
|
||||||
|
// 使用复合键:algorithmKey + ":" + componentId 确保唯一性
|
||||||
|
String componentKey = algorithmKey + ":" + componentId;
|
||||||
|
nodeMap.computeIfAbsent(componentKey, k -> {
|
||||||
|
TreeNode node = new TreeNode(componentId, componentName,algorithmId);
|
||||||
|
algorithmNode.getChildren().add(node); // 挂载到算法节点下
|
||||||
return node;
|
return node;
|
||||||
});
|
});
|
||||||
if (StrUtil.isNotBlank(algorithmId)) {
|
|
||||||
// 处理变电站层级
|
|
||||||
TreeNode areaNode = nodeMap.computeIfAbsent(algorithmId,
|
|
||||||
k -> {
|
|
||||||
TreeNode node = new TreeNode(algorithmId, algorithmClassName);
|
|
||||||
stationNode.getChildren().add(node); // 将变电站作为根节点
|
|
||||||
return node;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 处理区域层级
|
|
||||||
if (StrUtil.isNotBlank(componentId)) {
|
|
||||||
nodeMap.computeIfAbsent(componentId,
|
|
||||||
k -> {
|
|
||||||
TreeNode node = new TreeNode(componentId, componentName);
|
|
||||||
areaNode.getChildren().add(node);
|
|
||||||
return node;
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return roots;
|
return roots;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.yfd.platform.modules.algorithm.service.impl;
|
package com.yfd.platform.modules.algorithm.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmDevice;
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmDevice;
|
||||||
import com.yfd.platform.modules.algorithm.mapper.AlgorithmDeviceMapper;
|
import com.yfd.platform.modules.algorithm.mapper.AlgorithmDeviceMapper;
|
||||||
import com.yfd.platform.modules.algorithm.service.IAlgorithmDeviceService;
|
import com.yfd.platform.modules.algorithm.service.IAlgorithmDeviceService;
|
||||||
@ -9,6 +11,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -35,4 +38,12 @@ public class AlgorithmDeviceServiceImpl extends ServiceImpl<AlgorithmDeviceMappe
|
|||||||
});
|
});
|
||||||
return this.saveOrUpdateBatch(algorithmDeviceList);
|
return this.saveOrUpdateBatch(algorithmDeviceList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getAlgorithmDeviceParams(String algorithmId, String componentId) {
|
||||||
|
LambdaQueryWrapper<AlgorithmDevice> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(StrUtil.isNotBlank(algorithmId), AlgorithmDevice::getAlgorithmId, algorithmId);
|
||||||
|
queryWrapper.eq(StrUtil.isNotBlank(componentId), AlgorithmDevice::getComponentId, componentId).select(AlgorithmDevice::getDeviceName, AlgorithmDevice::getDeviceId, AlgorithmDevice::getParamValue);
|
||||||
|
return this.listMaps(queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,18 @@
|
|||||||
|
|
||||||
<select id="getAlgorithmComponentList" resultType="java.util.Map">
|
<select id="getAlgorithmComponentList" resultType="java.util.Map">
|
||||||
SELECT
|
SELECT
|
||||||
acc.*,ac.algorithm_class_name
|
acc.id,
|
||||||
|
acc.algorithm_id,
|
||||||
|
acc.station_code,
|
||||||
|
acc.station_name,
|
||||||
|
acc.component_id,
|
||||||
|
CONCAT( acc.main_device_name, '-', acc.component_name ) component_name,
|
||||||
|
ac.algorithm_class_name
|
||||||
FROM
|
FROM
|
||||||
iis_algorithm_class ac
|
iis_algorithm_class ac
|
||||||
INNER JOIN iis_algorithm_class_component acc ON ac.id = acc.algorithm_id
|
INNER JOIN iis_algorithm_class_component acc ON ac.id = acc.algorithm_id
|
||||||
WHERE 1=1
|
WHERE
|
||||||
|
1 =1
|
||||||
<if test="algorithmClassName != null and algorithmClassName != ''">
|
<if test="algorithmClassName != null and algorithmClassName != ''">
|
||||||
AND ac.algorithm_class_name LIKE CONCAT('%',#{algorithmClassName},'%')
|
AND ac.algorithm_class_name LIKE CONCAT('%',#{algorithmClassName},'%')
|
||||||
</if>
|
</if>
|
||||||
|
Loading…
Reference in New Issue
Block a user