fix:优化逻辑

This commit is contained in:
weitang 2025-06-24 08:57:40 +08:00
parent e81c342acd
commit 883dbf42fc
5 changed files with 49 additions and 28 deletions

View File

@ -61,7 +61,7 @@ public class IEC104ClientRunner implements ApplicationRunner {
GatewayDevice::getIpAddr, GatewayDevice::getIecAddr);
queryWrapper.orderByAsc(GatewayDevice::getDeviceCode);
List<GatewayDevice> list = gatewayDeviceMapper.selectList(queryWrapper);
if (list.size() > 0) {
if (!list.isEmpty()) {
for (GatewayDevice gatewayDevice : list) {
Iec104Config iec104Config = new Iec104Config();
iec104Config.setFrameAmountMax((short) 10);

View File

@ -1,6 +1,10 @@
package com.yfd.platform.component.iec61850.client;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.beanit.iec61850bean.*;
import com.yfd.platform.component.WebSocketServer;
import com.yfd.platform.modules.auxcontrol.domain.DeviceSignal;
import com.yfd.platform.modules.auxcontrol.mapper.DeviceSignalMapper;
import com.yfd.platform.modules.auxcontrol.service.IDeviceWorkDataService;
import com.yfd.platform.modules.patroltask.service.IAlarmLogService;
@ -44,6 +48,7 @@ public class IEC61850ClientListener extends Thread implements ClientEventListene
alarmLogService.doAlaramRecord("IEC61850", "yc", null, node_name, node_value);
} else if ("ST".equals(value.getFc().name())) {
//遥信 状态值
String node_name = value.getChild("stVal").toString().split(":")[0].replace(".stVal", "");
BdaBoolean state = (BdaBoolean) value.getChild("stVal");
@ -55,6 +60,12 @@ public class IEC61850ClientListener extends Thread implements ClientEventListene
deviceSignalMapper.updateDeviceSignalValue_yx(node_name, node_value, datestr);
//执行报警处理生成设备自身报警记录status=1
alarmLogService.doAlaramRecord("IEC61850", "yx", null, node_name, node_value);
DeviceSignal deviceSignal =
deviceSignalMapper.selectOne(new LambdaQueryWrapper<DeviceSignal>().eq(DeviceSignal::getYxAddr, node_name).last("limit 1"));
if (deviceSignal != null) {
WebSocketServer.sendInfo("auxcontrol_" + deviceSignal.getSignalId(), node_value);
}
}
}
}

View File

@ -44,7 +44,6 @@ public class IEC61850Service {
clientSap.setTSelRemote(new byte[]{0, 1});
clientSap.setTSelLocal(new byte[]{0, 0});
clientSap.setApTitleCalled(new int[]{1, 1, 999, 1});
ClientAssociation clientAssociation = null;
try {
clientAssociation = clientSap.associate(InetAddress.getByName(gatewayDevice.getIpAddr()), 102, null,
@ -77,6 +76,7 @@ public class IEC61850Service {
//sendCommand("", "a397bf1d4042ae948d248b1f1856937e", "yk", "true");
//sendCommand("", "a397bf1d4042ae948d248b1f1856937e", "yt", "25.6");
} catch (ServiceError | IOException e) {
e.printStackTrace();
log.info("未能关联或检索设备的模型 {}: {}", gatewayDevice.getDeviceCode(), e.getMessage());
}
return true;
@ -103,10 +103,10 @@ public class IEC61850Service {
*/
public boolean sendCommand(String systemcode, String signalid, String type, String deviceType, String value) throws IOException,
ServiceError {
// value = getControlValue(deviceType, value);
// if (StrUtil.isBlank(value)) {
// return false;
// }
value = getControlValue(deviceType, value);
if (StrUtil.isBlank(value)) {
return false;
}
DeviceSignal deviceSignal = deviceSignalService.getById(signalid);
//辅控系统下属网关机状态监控
if (StrUtil.isNotEmpty(systemcode) && "10".equals(systemcode)) {
@ -193,13 +193,13 @@ public class IEC61850Service {
public String getControlValue(String type, String value) {
if ("7".equals(type)) {
return value.equals("1") ? "false" : "true";
return value.equals("1") ? "0" : "1";
}
if ("14".equals(type)) {
return value.equals("1") ? "false" : "true";
return value.equals("1") ? "0" : "1";
}
if ("20".equals(type)) {
return value.equals("1") ? "false" : "true";
return value.equals("1") ? "0" : "1";
}
return null;
}

View File

@ -431,17 +431,23 @@ public class AlgorithmArrangeController {
@GetMapping("/viewFile")
@ApiOperation("预览方案图片")
public void serveVideo(String id, String type, HttpServletResponse response) {
public void serveVideo(String id, String type, HttpServletResponse response) throws IOException {
AlgorithmArrange algorithmArrange = algorithmArrangeService.getById(id);
if (algorithmArrange == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "布点数据不存在");
return;
}
String filePath = null;
if ("1".equals(type) && StrUtil.isNotBlank(algorithmArrange.getImageUrl())) {
FileUtil.serveVideo(httpServerConfig.getPlanFilePath(), algorithmArrange.getImageUrl(), response);
filePath = algorithmArrange.getImageUrl();
} else if ("2".equals(type) && StrUtil.isNotBlank(algorithmArrange.getArrangeImageUrl())) {
filePath = algorithmArrange.getArrangeImageUrl();
}
if ("2".equals(type) && StrUtil.isNotBlank(algorithmArrange.getArrangeImageUrl())) {
FileUtil.serveVideo(httpServerConfig.getPlanFilePath(), algorithmArrange.getArrangeImageUrl(), response);
if (filePath == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "文件路径无效");
return;
}
FileUtil.serveVideo(httpServerConfig.getPlanFilePath(), filePath, response);
}
private List<Map<String, Object>> getMapData() {

View File

@ -77,7 +77,6 @@ public class AnalyseCallController {
@Resource
private ISubstationDeviceService substationDeviceService;
@PostMapping("/picAnalyseRetNotify")
@ApiOperation("智能分析识别通知")
public Object picAnalyseRetNotify(@RequestBody String params) {
@ -106,7 +105,8 @@ public class AnalyseCallController {
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());;
log.error(e.getMessage());
;
result.put("code", "500");
}
return result;
@ -183,6 +183,9 @@ public class AnalyseCallController {
}
String originfilename = "";
if (StrUtil.isBlank(filename)) {
return;
}
if (StrUtil.isNotEmpty(type) && type.equals("alarm")) {//报警显示不同目录
originfilename = Config.getAlarmFilePath() + filename;
} else {
@ -293,7 +296,8 @@ public class AnalyseCallController {
// jsonObject1.putOnce("stationId", algorithmModel.getStationId());
// jsonObject1.putOnce("version", algorithmModel.getVersion());
// String token = getToken();
// httpUtil.sendHeaderHttpPost("json", algorithmServerConfig.getServerIp(), algorithmServerConfig.getHttpPort(), "", token,
// httpUtil.sendHeaderHttpPost("json", algorithmServerConfig.getServerIp(), algorithmServerConfig
// .getHttpPort(), "", token,
// "recogApi/updateAlgorithmVersion", jsonObject1, null);
}
}