优化逻辑

This commit is contained in:
weitang 2025-05-15 16:53:29 +08:00
parent ba38006687
commit 44576b6147
20 changed files with 245 additions and 55 deletions

View File

@ -151,8 +151,8 @@ user-settings:
- http://192.168.1.8:3000
# 项目中扩展辅助设置
station:
id: 9b4e9d9f70b2256a69dfcbdecb13c960
staion_code: 500KV00001
staion_name: 500Kv标准验证变电站
id: 35c4e466ddd9809445d3f880f94b4a2f
staion_code: 7FE4BB37-F54A-4808-852B-6CAB43DD71B3-00001
staion_name: 500V变电站
snapfilepath: d:\riis\parent-snapimage\ #上级单位视频截图保存路径
ffmpegpath: E:\ffmpeg\bin\ #ffmpeg 工具目录

View File

@ -63,7 +63,8 @@ public class VoiceServerServiceImpl implements VoiceServerService {
e.printStackTrace();
}
if ("OFF".equals(actionPower)) {
this.createAudioFile(fileName);
FileUtil.copy("D:\\riis\\video\\sound.wav", httpServerConfig.getSnapFilePath() + fileName, true);
// this.createAudioFile(fileName);
}
return true;
}

View File

@ -6,6 +6,7 @@ import com.yfd.platform.config.ResponseResult;
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
import com.yfd.platform.modules.algorithm.domain.AlgorithmParamsRequest;
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.ApiOperation;
import org.springframework.web.bind.annotation.*;
@ -40,6 +41,13 @@ public class AlgorithmClassController {
return ResponseResult.successData(list);
}
@GetMapping("/getAlgorithmClassTree")
@ApiOperation("获取算法分类树")
public ResponseResult getAlgorithmClassTree(String algorithmClassName) {
List<TreeNode> treeNodes = algorithmClassService.getAlgorithmComponentTree(algorithmClassName);
return ResponseResult.successData(treeNodes);
}
@PostMapping("/addAlgorithmClass")
@ApiOperation("新增算法分类")
public ResponseResult addAlgorithmClass(@RequestBody AlgorithmClass algorithmClass) {
@ -86,4 +94,18 @@ public class AlgorithmClassController {
return ResponseResult.error();
}
}
@PostMapping("/callAlgorithmAnalyse")
@ApiOperation("调用算法分析")
public ResponseResult callAlgorithmAnalyse(String id) {
if (StrUtil.isBlank(id)) {
return ResponseResult.error("算法分类id为空");
}
boolean isOK = algorithmClassService.deleteAlgorithmClass(id);
if (isOK) {
return ResponseResult.success();
} else {
return ResponseResult.error();
}
}
}

View File

@ -38,7 +38,7 @@ public class AlgorithmDevice implements Serializable {
* 算法分类id
*/
@ApiModelProperty("算法分类id")
private String algorithm_id;
private String algorithmId;
/**
* 参数id

View File

@ -3,6 +3,9 @@ package com.yfd.platform.modules.algorithm.mapper;
import com.yfd.platform.modules.algorithm.domain.AlgorithmClassComponent;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
import java.util.Map;
/**
* <p>
* Mapper 接口
@ -13,4 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface AlgorithmClassComponentMapper extends BaseMapper<AlgorithmClassComponent> {
List<Map<String, Object>> getAlgorithmComponentList(String algorithmClassName);
}

View File

@ -3,6 +3,9 @@ package com.yfd.platform.modules.algorithm.service;
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yfd.platform.modules.algorithm.domain.AlgorithmParamsRequest;
import com.yfd.platform.modules.basedata.domain.TreeNode;
import java.util.List;
/**
* <p>
@ -36,6 +39,18 @@ public interface IAlgorithmClassService extends IService<AlgorithmClass> {
***********************************/
boolean deleteAlgorithmClass(String id);
/**********************************
* 用途说明: 保存算法分类和算法参数
* 参数说明 algorithmParamsRequest
* 返回值说明: boolean
***********************************/
boolean addAlgorithmClassAndParams(AlgorithmParamsRequest algorithmParamsRequest);
/***********************************
* 用途说明: 获取算法分类树
* 参数说明 algorithmClassName
* 返回值说明: java.util.List<com.yfd.platform.modules.basedata.domain.TreeNode>
***********************************/
List<TreeNode> getAlgorithmComponentTree(String algorithmClassName);
}

View File

@ -8,18 +8,23 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
import com.yfd.platform.modules.algorithm.domain.AlgorithmParams;
import com.yfd.platform.modules.algorithm.domain.AlgorithmParamsRequest;
import com.yfd.platform.modules.algorithm.mapper.AlgorithmClassComponentMapper;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -36,6 +41,9 @@ public class AlgorithmClassServiceImpl extends ServiceImpl<AlgorithmClassMapper,
@Resource
private IAlgorithmParamsService algorithmParamsService;
@Resource
private AlgorithmClassComponentMapper algorithmClassComponentMapper;
/**********************************
* 用途说明: 新增算法分类
* 参数说明 algorithmClass
@ -74,6 +82,11 @@ public class AlgorithmClassServiceImpl extends ServiceImpl<AlgorithmClassMapper,
throw new RuntimeException("删除错误");
}
/**********************************
* 用途说明: 保存算法分类和算法参数
* 参数说明 algorithmParamsRequest
* 返回值说明: boolean
***********************************/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean addAlgorithmClassAndParams(AlgorithmParamsRequest algorithmParamsRequest) {
@ -96,4 +109,71 @@ public class AlgorithmClassServiceImpl extends ServiceImpl<AlgorithmClassMapper,
});
return algorithmParamsService.saveOrUpdateBatch(algorithmParamsList);
}
/***********************************
* 用途说明: 获取算法分类树
* 参数说明 algorithmClassName
* 返回值说明: java.util.List<com.yfd.platform.modules.basedata.domain.TreeNode>
***********************************/
@Override
public List<TreeNode> getAlgorithmComponentTree(String algorithmClassName) {
List<Map<String, Object>> dataList =
algorithmClassComponentMapper.getAlgorithmComponentList(algorithmClassName);
List<TreeNode> treeNodes = this.buildSignalTree(dataList);
if (treeNodes.size() <= 0) {
return treeNodes;
}
return treeNodes.get(0).getChildren();
}
/**********************************
* 用途说明: 构造树
* 参数说明 dataList 数据
* 返回值说明: java.util.List<com.yfd.platform.modules.basedata.domain.TreeNode>
***********************************/
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 stationCode = (String) data.get("stationCode");
String stationName = (String) data.get("stationName");
String algorithmId = (String) data.get("algorithmId");
String algorithmClassName = (String) data.get("algorithmClassName");
String componentId = (String) data.get("componentId");
String componentName = (String) data.get("componentName");
TreeNode stationNode = nodeMap.computeIfAbsent(stationCode,
k -> {
TreeNode node = new TreeNode(stationCode, stationName);
roots.add(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;
}
}

View File

@ -1,5 +1,6 @@
package com.yfd.platform.modules.auxcontrol.controller;
import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yfd.platform.config.ResponseResult;
import com.yfd.platform.modules.auxcontrol.domain.DeviceSignal;
@ -67,7 +68,7 @@ public class DeviceWorkDataController {
}
// 按分钟分组数据
Map<LocalDateTime, BigDecimal> minuteDataMap = new HashMap<>();
Map<LocalDateTime, String> minuteDataMap = new HashMap<>();
for (DeviceWorkData data : deviceWorkDataList) {
LocalDateTime minuteKey = data.getStartTime().truncatedTo(ChronoUnit.MINUTES);
minuteDataMap.put(minuteKey, data.getValue());
@ -79,8 +80,11 @@ public class DeviceWorkDataController {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH时mm分");
for (LocalDateTime slot : minuteSlots) {
xAxisData.add(slot.format(formatter));
BigDecimal value = minuteDataMap.getOrDefault(slot, BigDecimal.ZERO);
seriesData.add(value.doubleValue());
String value = minuteDataMap.getOrDefault(slot, "0");
if (!NumberUtil.isDouble(value)) {
value="0";
}
seriesData.add(NumberUtil.parseDouble(value));
}
// 构建ECharts数据结构

View File

@ -77,7 +77,7 @@ public class DeviceWorkData implements Serializable {
/**
*
*/
private BigDecimal value;
private String value;
/**
* 备用1

View File

@ -59,7 +59,7 @@ public class DeviceWorkDataServiceImpl extends ServiceImpl<DeviceWorkDataMapper,
workdata.setSignalId(map.get("signalId").toString());
workdata.setSignalName(map.get("signalName").toString());
workdata.setUnit(ObjUtil.isNotEmpty(map.get("signalUnit")) ? map.get("signalUnit").toString() : "");
workdata.setValue(new BigDecimal(value));
workdata.setValue(value);
if (StrUtil.isEmpty(dateTimeString) || "null".equals(dateTimeString)) {
workdata.setStartTime(LocalDateTime.now());
} else {

View File

@ -124,7 +124,7 @@ public class SubstationPatroldeviceController {
}
}
if ("1".equals(flag)) {
queryWrapper.and(i -> i.isNull(SubstationPatroldevice::getStationId).or().eq(SubstationPatroldevice::getStationId, ""));
queryWrapper.and(i -> i.isNull(SubstationPatroldevice::getAreaId).or().eq(SubstationPatroldevice::getAreaId, ""));
} else {
queryWrapper.eq(SubstationPatroldevice::getStationId, stationId);
if (StrUtil.isNotBlank(areaId)) {

View File

@ -593,51 +593,75 @@ public class SubstationPatroldeviceServiceImpl extends ServiceImpl<SubstationPat
}
List<SubstationPatroldevice> list = this.list(queryWrapper);
List<Map<String, Object>> mapList = new ArrayList<>();
List<Map<String, Object>> patrolEquipmentType = sysDictionaryItemsService.getDeviceByType(
Map<String, Object> patrolEquipmentType = sysDictionaryItemsService.getDeviceMapByType(
"PatrolEquipmentType");
JSONObject patrolEquipmentTypeMap=JSONUtil.parseObj(patrolEquipmentType.get("resultMap"));
for (SubstationPatroldevice substationPatroldevice : list) {
String devtype = "";
for (Map<String, Object> map : patrolEquipmentType) {
String itemcode = (String) map.get("itemcode");
if (itemcode.equals(type)) {
devtype = map.get("dictname").toString();
break;
}
}
Map<String, Object> manuFacturer = sysDictionaryItemsService.getDeviceMapByType(
"ManuFacturer");
JSONObject manuFacturerMap=JSONUtil.parseObj(manuFacturer.get("resultMap"));
for (int i = 0; i < list.size(); i++) {
SubstationPatroldevice substationPatroldevice = list.get(i);
String devtype = StrUtil.isNotBlank(type) ? patrolEquipmentTypeMap.getStr(type) : "";
Map<String, Object> map = new LinkedHashMap<>();
map.put("devtype", devtype);
map.put("devname", substationPatroldevice.getPatroldeviceName());
map.put("devdesc", "");
map.put("devmodel", substationPatroldevice.getDeviceModel());
map.put("manufacturer", substationPatroldevice.getManufacturer());
map.put("madein", "");
map.put("productionnum", substationPatroldevice.getProductionCode());
map.put("productiondate", substationPatroldevice.getProductionDate());
map.put("phyassetID", substationPatroldevice.getMaterialId());
map.put("position_x", "");
map.put("position_y", "");
map.put("region", "");
map.put("cabinet", "");
map.put("hwRev", "");
map.put("SwRev", "");
if ("1".equals(type) || "2".equals(type) || "3".equals(type)) {
map.put("SwRevCRC", "");
map.put("IPAddr", substationPatroldevice.getIpaddr());
map.put("MacAddr", substationPatroldevice.getMacaddr());
} else if ("10".equals(type)) {
map.put("SwRevCRC", "");
map.put("IPAddr", substationPatroldevice.getIpaddr());
map.put("MacAddr", substationPatroldevice.getMacaddr());
} else if ("11".equals(type)) {
map.put("SwRevCRC", "");
map.put("IPAddr", substationPatroldevice.getIpaddr());
map.put("MacAddr", substationPatroldevice.getMacaddr());
} else if ("13".equals(type)) {
}
map.put("序号", (i + 1));
map.put("设备名称", substationPatroldevice.getPatroldeviceName());
map.put("设备类型", devtype);
map.put("设备型号", substationPatroldevice.getDeviceModel());
map.put("设备来源", substationPatroldevice.getDeviceSource());
String manufacturerName = StrUtil.isNotBlank(substationPatroldevice.getManufacturer()) ? manuFacturerMap.getStr(substationPatroldevice.getManufacturer()) : "";
map.put("生产厂家", manufacturerName);
map.put("安装位置", substationPatroldevice.getPlace());
String online = "1".equals(substationPatroldevice.getOnline()) ? "在线" : "离线";
map.put("实时状态", online);
String datastatus = "1".equals(substationPatroldevice.getDatastatus()) ? "有效" : "无效";
map.put("设备状态", datastatus);
mapList.add(map);
}
// for (SubstationPatroldevice substationPatroldevice : list) {
// String devtype = "";
// for (Map<String, Object> map : patrolEquipmentType) {
// String itemcode = (String) map.get("itemcode");
// if (itemcode.equals(type)) {
// devtype = map.get("dictname").toString();
// break;
// }
// }
// Map<String, Object> map = new LinkedHashMap<>();
// map.put("devtype", devtype);
// map.put("devname", substationPatroldevice.getPatroldeviceName());
// map.put("devdesc", "");
// map.put("devmodel", substationPatroldevice.getDeviceModel());
// map.put("manufacturer", substationPatroldevice.getManufacturer());
// map.put("madein", "");
// map.put("productionnum", substationPatroldevice.getProductionCode());
// map.put("productiondate", substationPatroldevice.getProductionDate());
// map.put("phyassetID", substationPatroldevice.getMaterialId());
// map.put("position_x", "");
// map.put("position_y", "");
// map.put("region", "");
// map.put("cabinet", "");
// map.put("hwRev", "");
// map.put("SwRev", "");
// if ("1".equals(type) || "2".equals(type) || "3".equals(type)) {
// map.put("SwRevCRC", "");
// map.put("IPAddr", substationPatroldevice.getIpaddr());
// map.put("MacAddr", substationPatroldevice.getMacaddr());
// } else if ("10".equals(type)) {
// map.put("SwRevCRC", "");
// map.put("IPAddr", substationPatroldevice.getIpaddr());
// map.put("MacAddr", substationPatroldevice.getMacaddr());
// } else if ("11".equals(type)) {
// map.put("SwRevCRC", "");
// map.put("IPAddr", substationPatroldevice.getIpaddr());
// map.put("MacAddr", substationPatroldevice.getMacaddr());
// } else if ("13".equals(type)) {
//
// }
// mapList.add(map);
// }
// String[] headers = {"设备类型", "设备名称", "中文描述", "设备型号", "生产厂家", "生产国家", "出厂编号", "出厂日期", "实物 ID",
// "相对空间位置 x", "相对空间位置 y", "所属区域标识"};
// String[] keys = { "devtype", "devname", "devdesc", "devmodel","manufacturer", "madein",

View File

@ -19,6 +19,8 @@ import com.yfd.platform.modules.basedata.domain.DeviceChannel;
import com.yfd.platform.modules.basedata.service.IDeviceChannelService;
import com.yfd.platform.modules.basedata.service.ISubstationDeviceService;
import com.yfd.platform.modules.patroltask.domain.AlarmLog;
import com.yfd.platform.modules.patroltask.domain.TaskResult;
import com.yfd.platform.modules.patroltask.mapper.TaskResultMapper;
import com.yfd.platform.modules.patroltask.service.IAlarmLogService;
import com.yfd.platform.modules.patroltask.service.ITaskTodoService;
import com.yfd.platform.utils.SecurityUtils;
@ -62,6 +64,9 @@ public class AlarmLogController {
@Resource
private DeviceSignalMapper deviceSignalMapper;
@Resource
private TaskResultMapper taskResultMapper;
@GetMapping("/getAlarmLogList")
@ApiOperation("查询报警信息")
public ResponseResult getAlarmLogList(String stationId) {
@ -289,7 +294,11 @@ public class AlarmLogController {
@ApiOperation("发送报警")
public ResponseResult sendAlarmById(String stationId,String id) {
AlarmLog alarmLog = alarmLogService.getById(id);
WebSocketServer.sendInfo(stationId, JSONUtil.parseObj(alarmLog).toString());
JSONObject jsonObject = JSONUtil.parseObj(alarmLog);
TaskResult taskResult = taskResultMapper.selectById(alarmLog.getTaskResultId());
jsonObject.putOpt("channelId", taskResult.getPatroldeviceChannelcode());
jsonObject.putOpt("deviceId", taskResult.getPatroldeviceCode());
WebSocketServer.sendInfo(stationId, jsonObject.toString());
return ResponseResult.success();
}

View File

@ -402,10 +402,10 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
}
try {
String patroldeviceCode = map.get("patroldeviceCode").toString();
// voiceServerService.sendVoiceServerControl(patroldeviceCode, "ON", fullfilename);
FileUtil.copy("D:\\riis\\video\\sound.wav", config.getSnapFilePath() + fullfilename, true);
voiceServerService.sendVoiceServerControl(patroldeviceCode, "ON", fullfilename);
// FileUtil.copy("D:\\riis\\video\\sound.wav", config.getSnapFilePath() + fullfilename, true);
Thread.sleep(duration * 1000);
// voiceServerService.sendVoiceServerControl(patroldeviceCode, "OFF", fullfilename);
voiceServerService.sendVoiceServerControl(patroldeviceCode, "OFF", fullfilename);
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yfd.platform.system.domain.SysDictionaryItems;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -15,4 +16,6 @@ import java.util.List;
*/
public interface SysDictionaryItemsMapper extends BaseMapper<SysDictionaryItems> {
List<SysDictionaryItems> getDictItemByType(String dictcode, String alarmType);
Map<String, Object> getDeviceMapByType(String dictcode);
}

View File

@ -53,6 +53,8 @@ public interface ISysDictionaryItemsService extends IService<SysDictionaryItems>
***********************************/
List<Map<String, Object>> getDeviceByType(String dictcode);
Map<String, Object> getDeviceMapByType(String dictcode);
List<SysDictionaryItems> getDictItemByType(String dictcode, String alarmType);
List<Map<String, Object>> getDictionaryItems(String dictCodes);

View File

@ -148,6 +148,11 @@ public class SysDictionaryItemsServiceImpl extends ServiceImpl<SysDictionaryItem
return itemCode;
}
@Override
public Map<String, Object> getDeviceMapByType(String dictcode) {
return sysDictionaryItemsMapper.getDeviceMapByType(dictcode);
}
@Override
public List<SysDictionaryItems> getDictItemByType(String dictcode, String alarmType) {
return sysDictionaryItemsMapper.getDictItemByType(dictcode, alarmType);

View File

@ -2,4 +2,15 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yfd.platform.modules.algorithm.mapper.AlgorithmClassComponentMapper">
<select id="getAlgorithmComponentList" resultType="java.util.Map">
SELECT
acc.*,ac.algorithm_class_name
FROM
iis_algorithm_class ac
INNER JOIN iis_algorithm_class_component acc ON ac.id = acc.algorithm_id
WHERE 1=1
<if test="algorithmClassName != null and algorithmClassName != ''">
AND ac.algorithm_class_name LIKE CONCAT('%',#{algorithmClassName},'%')
</if>
</select>
</mapper>

View File

@ -54,5 +54,6 @@
INNER JOIN iis_substation_component sc ON ds.main_component_id = sc.component_id
WHERE
sc.component_name = '微气象设备部件'
ORDER BY orderno
</select>
</mapper>

View File

@ -12,4 +12,13 @@
AND di.itemcode = #{alarmType}
limit 1
</select>
<select id="getDeviceMapByType" resultType="java.util.Map">
SELECT
JSON_OBJECTAGG(di.itemcode, di.dictname) AS result_map
FROM
sys_dictionary_items di
INNER JOIN sys_dictionary d ON di.dictid = d.id
WHERE
d.dictcode = #{dictcode};
</select>
</mapper>