From c561e51a17ffb154bc0d19dc3c73ef64ca60091d Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Fri, 5 Jan 2024 17:20:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ats/warn/axle/AxleLedInterlockTask.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/axle/AxleLedInterlockTask.java b/src/main/java/club/joylink/xiannccda/ats/warn/axle/AxleLedInterlockTask.java index eb624bb..3a1dee1 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/axle/AxleLedInterlockTask.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/axle/AxleLedInterlockTask.java @@ -22,7 +22,9 @@ import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section.SectionType import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Turnout; import club.joylink.xiannccda.service.AlertInfoService; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.protobuf.MessageOrBuilder; import java.time.LocalDateTime; @@ -82,18 +84,18 @@ public class AxleLedInterlockTask implements AlertMonitoringTask { Integer lineIdInt = Integer.parseInt(lineId); //收集联锁下的所有所有区段设备 List resultList = this.collectorLedWarDevices(findWarnAlertType, lineId, detail.getDevices()); + List occupidedDeviceList = resultList.stream().filter(d -> d.occupied).map(d -> d.deviceCode).toList(); if (resultList.stream().anyMatch(d -> d.occupied)) { - log.info("线路[{}] 联锁区[{}] 需要加载设备数量[{}] 实际加载数量[{}] 区段被占用情况[{}]", lineId, rtuIdJoinStr, deviceCount, resultList.size(), - resultList.stream().filter(d -> d.occupied).map(d -> d.deviceCode).collect(Collectors.joining(","))); + String occupedDevices = Joiner.on(StringPool.COMMA).join(occupidedDeviceList); + log.info("线路[{}] 联锁区[{}] 需要加载设备数量[{}] 实际加载数量[{}] 区段被占用情况[{}]", lineId, rtuIdJoinStr, deviceCount, resultList.size(), occupedDevices); } - int occupidedSzie = (int) resultList.stream().filter(d -> d.occupied).count(); + int occupidedSzie = occupidedDeviceList.size(); String customName = String.format("%s-%s", findWarnAlertType.name(), detail.getAreaConfigId()); if (occupidedSzie >= deviceCount) { //联锁报警 if (alertDataSource.putAlterDevice(lineIdInt, customName, warnAlertType.name())) { - NccAlertInfo alertInfoMost = this.alertInfoService.createAlert2(detail.getAreaConfigId(), warnAlertType, lineIdInt, LocalDateTime.now(), detail.getAreaConfigName(), null, - AlertDeviceType.DEVICE_TYPE_TRACK, - false); + NccAlertInfo alertInfoMost = this.alertInfoService.createAlert2(detail.getAreaConfigId(), warnAlertType, lineIdInt, LocalDateTime.now(), + detail.getAreaConfigName(), null, AlertDeviceType.DEVICE_TYPE_TRACK, false); alertManager.emit(alertInfoMost); } return Optional.empty();