diff --git a/ruoyi-system/src/main/java/com/ruoyi/board/domain/dto/AlertPlanAndPlanTypeDTO.java b/ruoyi-system/src/main/java/com/ruoyi/board/domain/dto/AlertPlanAndPlanTypeDTO.java index 259b5c19..f5d8eee1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/board/domain/dto/AlertPlanAndPlanTypeDTO.java +++ b/ruoyi-system/src/main/java/com/ruoyi/board/domain/dto/AlertPlanAndPlanTypeDTO.java @@ -18,7 +18,6 @@ public class AlertPlanAndPlanTypeDTO { private String typeName; - /** * 等级 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/board/domain/enums/AlertPlanType.java b/ruoyi-system/src/main/java/com/ruoyi/board/domain/enums/AlertPlanType.java index 369179ab..d737e9f6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/board/domain/enums/AlertPlanType.java +++ b/ruoyi-system/src/main/java/com/ruoyi/board/domain/enums/AlertPlanType.java @@ -1,7 +1,24 @@ package com.ruoyi.board.domain.enums; +import com.ruoyi.board.domain.PlanType; +import com.ruoyi.board.service.IPlanTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Component public class AlertPlanType { + static Map typeNameIDMap = new HashMap<>(); + + @Autowired + private IPlanTypeService planTypeService; + + public static int getPlanTypeByName(String planTypeName) { // 0:雾,1:雨,2:雪 switch (planTypeName) { @@ -15,4 +32,17 @@ public class AlertPlanType { return -1; } } + + public void setTypeNameIDMap() { + typeNameIDMap.clear(); + List planTypeList = planTypeService.list(); + typeNameIDMap.putAll(planTypeList.stream() + .collect(Collectors.toMap( + PlanType::getTypeName, + PlanType::getId + ))); + } + + + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/board/service/IAlertPlanService.java b/ruoyi-system/src/main/java/com/ruoyi/board/service/IAlertPlanService.java index 34ad1761..8c62a5fe 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/board/service/IAlertPlanService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/board/service/IAlertPlanService.java @@ -10,7 +10,9 @@ public interface IAlertPlanService extends MPJBaseService { List listPage(AlertPlan alertPlan); - AlertPlan getOneByTypeAndValue(Integer type, Double value); + AlertPlan getOneByTypeAndValue(Long type, Double value); AlertPlanAndPlanTypeDTO getDTOById(Long id); + + AlertPlan getOneByPresetContentId(Integer id, Integer typeId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/board/service/IBoardInfoService.java b/ruoyi-system/src/main/java/com/ruoyi/board/service/IBoardInfoService.java index 6165794c..a507a4e8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/board/service/IBoardInfoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/board/service/IBoardInfoService.java @@ -8,7 +8,7 @@ import java.util.List; public interface IBoardInfoService extends MPJBaseService { - BoardInfo getOneByIP(String ip); + BoardInfoAndRoadDTO getOneByIP(String ip); List listBoardInfoDTO(BoardInfo boardInfo); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/board/service/IPresetContentService.java b/ruoyi-system/src/main/java/com/ruoyi/board/service/IPresetContentService.java index e1a0091c..ff4a4531 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/board/service/IPresetContentService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/board/service/IPresetContentService.java @@ -8,7 +8,7 @@ import java.util.List; public interface IPresetContentService extends MPJBaseService { - PresetContent getOneByContentAndBoardSize(String content, String boardSize, Integer type); + PresetContent getOneByContentAndBoardSize(String content, String boardSize, Long type); List listDTO(PresetContent presetContent); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/board/service/IReleaseRecordService.java b/ruoyi-system/src/main/java/com/ruoyi/board/service/IReleaseRecordService.java index 9f2a7c04..d2c633c0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/board/service/IReleaseRecordService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/board/service/IReleaseRecordService.java @@ -7,8 +7,5 @@ import com.ruoyi.board.domain.dto.ReleaseRecordAndPresetContentDTO; import java.util.List; public interface IReleaseRecordService extends MPJBaseService { - - List listLatest2minRecordDtoByBoardId(Integer boardId); - List listLatest2minRecordByBoardId(Integer boardId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/board/service/impl/AlertPlanServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/board/service/impl/AlertPlanServiceImpl.java index b8eb0780..b4dc1924 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/board/service/impl/AlertPlanServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/board/service/impl/AlertPlanServiceImpl.java @@ -34,7 +34,7 @@ public class AlertPlanServiceImpl extends MPJBaseServiceImpl alertPlanLambdaQueryWrapper = new LambdaQueryWrapper<>(); + alertPlanLambdaQueryWrapper.eq(AlertPlan::getPresetContentId, id); + alertPlanLambdaQueryWrapper.eq(AlertPlan::getType, typeId); + return getOne(alertPlanLambdaQueryWrapper); + } + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/board/service/impl/BoardInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/board/service/impl/BoardInfoServiceImpl.java index dc5b38ec..3aac20c6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/board/service/impl/BoardInfoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/board/service/impl/BoardInfoServiceImpl.java @@ -1,6 +1,5 @@ package com.ruoyi.board.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.github.yulichang.base.MPJBaseServiceImpl; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.ruoyi.board.domain.BoardInfo; @@ -19,15 +18,24 @@ import java.util.List; public class BoardInfoServiceImpl extends MPJBaseServiceImpl implements IBoardInfoService { @Override - public BoardInfo getOneByIP(String ip) { - LambdaQueryWrapper boardInfoLambdaQueryWrapper = new LambdaQueryWrapper<>(); - boardInfoLambdaQueryWrapper.eq(BoardInfo::getBoardIp, ip); - return getOne(boardInfoLambdaQueryWrapper); + public BoardInfoAndRoadDTO getOneByIP(String ip) { + MPJLambdaWrapper eq = condition() + .eq(StringUtils.isNotEmpty(ip), BoardInfo::getBoardIp, ip); + return selectJoinOne(BoardInfoAndRoadDTO.class, eq); } @Override public List listBoardInfoDTO(BoardInfo boardInfo) { - MPJLambdaWrapper eq = new MPJLambdaWrapper() + MPJLambdaWrapper eq = condition() + .likeRight(StringUtils.isNotEmpty(boardInfo.getBoardName()), BoardInfo::getBoardName, boardInfo.getBoardName()) + .likeRight(StringUtils.isNotEmpty(boardInfo.getBoardMileage()), BoardInfo::getBoardMileage, boardInfo.getBoardMileage()) + .eq(StringUtils.isNotEmpty(boardInfo.getBoardRoadSection()), BoardInfo::getBoardRoadSection, boardInfo.getBoardRoadSection()); + return selectJoinList(BoardInfoAndRoadDTO.class, eq); + } + + + private MPJLambdaWrapper condition() { + return new MPJLambdaWrapper() .selectAll(BoardInfo.class) .select(RoadGroup::getRoadName) .selectAs(BoardType::getName, "board_size_name") @@ -36,10 +44,6 @@ public class BoardInfoServiceImpl extends MPJBaseServiceImpl implements IPresetContentService { @Override - public PresetContent getOneByContentAndBoardSize(String content, String boardSize, Integer type) { + public PresetContent getOneByContentAndBoardSize(String content, String boardSize, Long type) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper .eq(PresetContent::getContent, content) diff --git a/ruoyi-system/src/main/java/com/ruoyi/board/service/impl/ReleaseRecordServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/board/service/impl/ReleaseRecordServiceImpl.java index 2b3343ed..bd8f650a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/board/service/impl/ReleaseRecordServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/board/service/impl/ReleaseRecordServiceImpl.java @@ -20,23 +20,9 @@ import java.util.List; public class ReleaseRecordServiceImpl extends MPJBaseServiceImpl implements IReleaseRecordService { private static final Logger log = LoggerFactory.getLogger(ReleaseRecordServiceImpl.class); - @Override - public List listLatest2minRecordDtoByBoardId(Integer boardId) { - Date before2min = new Date(System.currentTimeMillis() - 30 * 60 * 1000); - return selectJoinList(ReleaseRecordAndPresetContentDTO.class, - new MPJLambdaWrapper() - .selectAll(ReleaseRecord.class) - .select(PresetContent::getInfoType) - .leftJoin(PresetContent.class, PresetContent::getId, ReleaseRecord::getPresetContentId) - .eq(ReleaseRecord::getBoardId, boardId) - .gt(ReleaseRecord::getCreateTime, before2min) - .eq(PresetContent::getPresetType, 0) - ); - } - @Override public List listLatest2minRecordByBoardId(Integer boardId) { - Date before2min = new Date(System.currentTimeMillis() - 30 * 60 * 1000); + Date before2min = new Date(System.currentTimeMillis() - 2 * 60 * 1000); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(ReleaseRecord::getBoardId, boardId) .gt(ReleaseRecord::getCreateTime, before2min); diff --git a/ruoyi-system/src/main/java/com/ruoyi/protocol/enums/ProtocolDefault.java b/ruoyi-system/src/main/java/com/ruoyi/protocol/enums/ProtocolDefault.java index 614d487f..5a81d30f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/protocol/enums/ProtocolDefault.java +++ b/ruoyi-system/src/main/java/com/ruoyi/protocol/enums/ProtocolDefault.java @@ -4,7 +4,7 @@ import lombok.Getter; @Getter public enum ProtocolDefault { - SanSi(1, "SanSi", 2929),; + SanSi(1, "三思", 2929),; private final Integer id; private final String name; private final Integer port; diff --git a/ruoyi-system/src/main/java/com/ruoyi/protocol/sansi/SanSiProtocol.java b/ruoyi-system/src/main/java/com/ruoyi/protocol/sansi/SanSiProtocol.java index ba62504e..41a05c46 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/protocol/sansi/SanSiProtocol.java +++ b/ruoyi-system/src/main/java/com/ruoyi/protocol/sansi/SanSiProtocol.java @@ -1,8 +1,8 @@ package com.ruoyi.protocol.sansi; import com.alibaba.fastjson2.JSON; -import com.ruoyi.board.domain.BoardInfo; import com.ruoyi.board.domain.PresetContent; +import com.ruoyi.board.domain.dto.BoardInfoAndRoadDTO; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.protocol.enums.ProtocolDefault; @@ -32,7 +32,7 @@ public class SanSiProtocol implements IProtocolService { private static final Logger log = LoggerFactory.getLogger(SanSiProtocol.class); Integer deviceId = 0; - private String createTextItem(List presetContentList, BoardInfo boardInfo) { + private String createTextItem(List presetContentList, BoardInfoAndRoadDTO boardInfo) { Animation animation = new Animation(); animation.setInAnimation(0); animation.setInAnimationSpeed(200); @@ -41,8 +41,8 @@ public class SanSiProtocol implements IProtocolService { int index = 1; presetContentList.forEach(i -> { TextBase textBase = new TextBase(0, i.getContent()); - textBase.setFontSize(i.getFontSize()+","+i.getFontSize()); - textBase.setFontName(SanSiFontStyle.getStyleValueByName(i.getFontStyle())); + textBase.setFontSize(i.getFontSize() + "," + i.getFontSize()); + textBase.setFontName(SanSiFontStyle.getStyleValueByName(i.getFontFamily())); textBase.setWordSpace(i.getLetterSpacing()); BaseColour fontColour = SanSiFontColor.getBaseColourByColorName(i.getFontColor()); if (null == fontColour) { @@ -56,7 +56,6 @@ public class SanSiProtocol implements IProtocolService { textPlayItem.setY(i.getFontPositionY()); playItemList.add(textPlayItem); }); - String boardSize = boardInfo.getBoardSize(); String[] split = StringUtils.split(boardSize, "*"); if (split.length < 2) { @@ -67,12 +66,12 @@ public class SanSiProtocol implements IProtocolService { int width = Integer.parseInt(split[1]); AreaPositon areaPositon = new AreaPositon(0, 0, height, width, 0); - AreaItem areaItem = new AreaItem("1", "areaItem", areaPositon, playItemList); + AreaItem areaItem = new AreaItem("2", "areaItem", areaPositon, playItemList); List areaItemList = new ArrayList<>(); areaItemList.add(areaItem); - PageItem pageItem = new PageItem("1", "pageItem", areaItemList); + PageItem pageItem = new PageItem("2", "pageItem", areaItemList); PlayListFcms plf = new PlayListFcms(); String path = "./protocolFile/SanSi/" + DateUtils.dateTimeNow(); @@ -93,19 +92,16 @@ public class SanSiProtocol implements IProtocolService { @Override public boolean protocolSupport(String protocolName) { - return StringUtils.equals(ProtocolDefault.SanSi.getName(), protocolName); + return StringUtils.contains(protocolName, ProtocolDefault.SanSi.getName()); } @Override - public void loginDevice(BoardInfo boardInfo) { + public void loginDevice(BoardInfoAndRoadDTO boardInfo) { if (deviceId > 10) { deviceId = 0; } deviceId++; - if (boardInfo.getBoardPort()<1) { - boardInfo.setBoardPort(ProtocolDefault.SanSi.getPort()); - } - DeviceVar.deviceInforInit(Integer.toString(deviceId), 1, boardInfo.getBoardIp(), boardInfo.getBoardPort(), 2048); + DeviceVar.deviceInforInit(Integer.toString(deviceId), 1, boardInfo.getBoardIp(), ProtocolDefault.SanSi.getPort(), 2048); } @Override @@ -114,7 +110,7 @@ public class SanSiProtocol implements IProtocolService { } @Override - public void publishContent(BoardInfo boardInfo, List presetContentList) { + public void publishContent(BoardInfoAndRoadDTO boardInfo, List presetContentList) { String path = createTextItem(presetContentList, boardInfo); uploadAndStartPlayList(path); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/protocol/sansi/enums/SanSiFontStyle.java b/ruoyi-system/src/main/java/com/ruoyi/protocol/sansi/enums/SanSiFontStyle.java index 7d7fe4b9..01aaeafd 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/protocol/sansi/enums/SanSiFontStyle.java +++ b/ruoyi-system/src/main/java/com/ruoyi/protocol/sansi/enums/SanSiFontStyle.java @@ -6,7 +6,9 @@ import java.util.stream.Stream; @Getter public enum SanSiFontStyle { - SongTi("宋体", "s"); + SongTi("SimSun", "s"), + HeiTi("SimHei", "h"), + KaiTi("KaiTi", "k"); private final String name; private final String value; diff --git a/ruoyi-system/src/main/java/com/ruoyi/protocol/service/IProtocolService.java b/ruoyi-system/src/main/java/com/ruoyi/protocol/service/IProtocolService.java index 02c745f5..fe405a1f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/protocol/service/IProtocolService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/protocol/service/IProtocolService.java @@ -1,7 +1,7 @@ package com.ruoyi.protocol.service; -import com.ruoyi.board.domain.BoardInfo; import com.ruoyi.board.domain.PresetContent; +import com.ruoyi.board.domain.dto.BoardInfoAndRoadDTO; import java.util.List; @@ -9,13 +9,13 @@ public interface IProtocolService { boolean protocolSupport(String protocolName); - void loginDevice(BoardInfo boardInfo); + void loginDevice(BoardInfoAndRoadDTO boardInfo); void logoutDevice(); - void publishContent(BoardInfo boardInfo, List presetContentList); + void publishContent(BoardInfoAndRoadDTO boardInfo, List presetContentList); - default void publishInformation(BoardInfo boardInfo, List presetContentList){ + default void publishInformation(BoardInfoAndRoadDTO boardInfo, List presetContentList){ // 登录 loginDevice(boardInfo); // 发布 diff --git a/ruoyi-system/src/main/java/com/ruoyi/protocol/service/impl/ContentPublishingService.java b/ruoyi-system/src/main/java/com/ruoyi/protocol/service/impl/ContentPublishingService.java index 7fb80a1e..18522b7b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/protocol/service/impl/ContentPublishingService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/protocol/service/impl/ContentPublishingService.java @@ -1,7 +1,7 @@ package com.ruoyi.protocol.service.impl; -import com.ruoyi.board.domain.BoardInfo; import com.ruoyi.board.domain.PresetContent; +import com.ruoyi.board.domain.dto.BoardInfoAndRoadDTO; import com.ruoyi.protocol.service.IProtocolService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,8 +16,8 @@ public class ContentPublishingService { @Autowired List protocolServiceList; - public void contentPublish(BoardInfo boardInfo, List presetContentList) { - IProtocolService iProtocolService = protocolServiceList.stream().filter(i -> i.protocolSupport(boardInfo.getBoardCommunicationProtocol())).findFirst().orElse(null); + public void contentPublish(BoardInfoAndRoadDTO boardInfo, List presetContentList) { + IProtocolService iProtocolService = protocolServiceList.stream().filter(i -> i.protocolSupport(boardInfo.getBoardProtocolName())).findFirst().orElse(null); if (iProtocolService ==null) { log.error("协议不支持"); return; diff --git a/ruoyi-system/src/main/java/com/ruoyi/sensor/service/ISensorDataService.java b/ruoyi-system/src/main/java/com/ruoyi/sensor/service/ISensorDataService.java index 7a4b06e1..823030f5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/sensor/service/ISensorDataService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/sensor/service/ISensorDataService.java @@ -9,4 +9,6 @@ public interface ISensorDataService { void putPerceptionParamsToMap(PerceptionParams perceptionParams); void handlerPerceptionMap(); + + void setPlanTypeNameIdMap(); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/sensor/service/impl/SensorDataServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/sensor/service/impl/SensorDataServiceImpl.java index 8d2c733d..e21779fb 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/sensor/service/impl/SensorDataServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/sensor/service/impl/SensorDataServiceImpl.java @@ -1,14 +1,8 @@ package com.ruoyi.sensor.service.impl; -import com.ruoyi.board.domain.AlertPlan; -import com.ruoyi.board.domain.BoardInfo; -import com.ruoyi.board.domain.PresetContent; -import com.ruoyi.board.domain.ReleaseRecord; -import com.ruoyi.board.domain.enums.AlertPlanType; -import com.ruoyi.board.service.IAlertPlanService; -import com.ruoyi.board.service.IBoardInfoService; -import com.ruoyi.board.service.IPresetContentService; -import com.ruoyi.board.service.IReleaseRecordService; +import com.ruoyi.board.domain.*; +import com.ruoyi.board.domain.dto.BoardInfoAndRoadDTO; +import com.ruoyi.board.service.*; import com.ruoyi.protocol.service.impl.ContentPublishingService; import com.ruoyi.sensor.common.PerceptionHandlerMap; import com.ruoyi.sensor.domain.PerceptionParams; @@ -19,7 +13,6 @@ import com.ruoyi.sensor.domain.dto.PerceptionHandlerDTO; import com.ruoyi.sensor.enums.PrintColor; import com.ruoyi.sensor.merchants.MerchantsHttp; import com.ruoyi.sensor.service.ISensorDataService; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,11 +40,19 @@ public class SensorDataServiceImpl implements ISensorDataService { private IReleaseRecordService releaseRecordService; @Autowired private ContentPublishingService contentPublishingService; + @Autowired + private IPlanTypeService planTypeService; + + private static final Map planTypeNameIdMap = new HashMap<>(); @Override @Async public void perceptionParamsHandler(PerceptionParams params) { - int currentContentPlanType = AlertPlanType.getPlanTypeByName(params.getPerceptionType()); + long currentContentPlanType = planTypeNameIdMap.getOrDefault(params.getPerceptionType(), (long) -1); + if (currentContentPlanType == -1) { + log.error("没有这个预警的类型"); + return; + } // 找到符合计划的预警 AlertPlan currentAlertPlan = alertPlanService.getOneByTypeAndValue(currentContentPlanType, params.getPerceptionValue()); if (null == currentAlertPlan) { @@ -59,13 +60,13 @@ public class SensorDataServiceImpl implements ISensorDataService { return; } // 情报板设备信息 - BoardInfo boardInfo = boardInfoService.getOneByIP(params.getBoardIp()); + BoardInfoAndRoadDTO boardInfo = boardInfoService.getOneByIP(params.getBoardIp()); if (null == boardInfo) { log.error("找不到情报板信息"); return; } // 预置发布的信息 - PresetContent currentContent = presetContentService.getOneByContentAndBoardSize(currentAlertPlan.getDisplayContent(), boardInfo.getBoardSize(), currentContentPlanType); + PresetContent currentContent = presetContentService.getById(currentAlertPlan.getPresetContentId()); if (null == currentContent) { log.error("找不到预置发布的信息"); return; @@ -80,7 +81,7 @@ public class SensorDataServiceImpl implements ISensorDataService { informationToBeReleasedList.add(currentContent); } else { // 如果不为空,说明 2 分钟内是发布了内容的,查询所有的发布内容 - List presetContentIdList = releaseRecordList.stream().map(ReleaseRecord::getPresetContentId).collect(Collectors.toList()); + Set presetContentIdList = releaseRecordList.stream().map(ReleaseRecord::getPresetContentId).collect(Collectors.toSet()); List existPresetContentList = presetContentService.listByIds(presetContentIdList); // 先把已经存在的都加入进去 informationToBeReleasedList.addAll(existPresetContentList); @@ -93,36 +94,24 @@ public class SensorDataServiceImpl implements ISensorDataService { // 说明这是一个已有的类型,需要获取预警等级,然后进行判断 // 判断已有类型是否和现在的一样然后再替换掉 // 现在需要知道这个同类型的属于是哪个级别的 - int foundPlanId = releaseRecordList.stream() - .filter(i -> Objects.equals(i.getPresetContentId(), isExistsPresetContent.getId())) - .mapToInt(ReleaseRecord::getPlanId) - .findFirst().orElse(-1); - AlertPlan byId = alertPlanService.getById(foundPlanId); - int compare = NumberUtils.compare(byId.getLevel(), - currentAlertPlan.getLevel()); - switch (compare) { - case 0: - // 两个一样等级 - // 这时候就不需要替换,也不需要重新发布 - presetStatus = "预警持续"; - break; - case 1: - // getPresetContentLevel > alertPlan.getLevel() - // 预警减弱 - // 此时需要将同类型的信息给替换掉,并重新发布 - presetStatus = "预警减弱"; - break; - case -1: - // getPresetContentLevel < alertPlan.getLevel() - // 预警加强 - // 此时需要将同类型的信息给替换掉,并重新发布 - presetStatus = "预警加强"; - break; - } - // 替换同类型的预警信息 - for (int i = 0; i < existPresetContentList.size(); i++) { - if (existPresetContentList.get(i).getInfoType() == currentContentPlanType) { - existPresetContentList.set(i, currentContent); + AlertPlan existContentAlertPlan = alertPlanService.getOneByPresetContentId(isExistsPresetContent.getId(), currentAlertPlan.getType()); + if (existContentAlertPlan != null) { + switch (currentAlertPlan.getMinValue().compareTo(existContentAlertPlan.getMinValue())) { + case 0: + presetStatus = "预警持续"; + break; + case 1: + presetStatus = "预警加强"; + break; + case -1: + presetStatus = "预警减弱"; + break; + } + // 替换同类型的预警信息 + for (int i = 0; i < informationToBeReleasedList.size(); i++) { + if (informationToBeReleasedList.get(i).getInfoType() == currentContentPlanType) { + informationToBeReleasedList.set(i, currentContent); + } } } } @@ -133,9 +122,11 @@ public class SensorDataServiceImpl implements ISensorDataService { // 发布之后记录发布内容 ReleaseRecord this.saveRecord(boardInfo.getId(), currentContent.getId(), currentAlertPlan.getId()); // 记录完了之后就需要向对方发送状态日志记录 - this.sendStatus(presetStatus, boardInfo.getBoardIp(), params.getPerceptionType(), currentContent.getContent(), params.getPerceptionValue(), currentAlertPlan.getLevel()); +// this.sendStatus(presetStatus, boardInfo.getBoardIp(), params.getPerceptionType(), currentContent.getContent(), params.getPerceptionValue(), currentAlertPlan.getLevel()); + this.sendStatus(presetStatus, boardInfo.getBoardIp(), params.getPerceptionType(), currentContent.getContent(), params.getPerceptionValue(), 1); // 发送情报板发布信息日志记录 - this.sendPublicLog(boardInfo.getBoardIp(), params.getPerceptionType(), currentAlertPlan.getLevel(), currentContent.getContent(), informationToBeReleasedList); +// this.sendPublicLog(boardInfo.getBoardIp(), params.getPerceptionType(), currentAlertPlan.getLevel(), currentContent.getContent(), informationToBeReleasedList); + this.sendPublicLog(boardInfo.getBoardIp(), params.getPerceptionType(), 1, currentContent.getContent(), informationToBeReleasedList); } @Override @@ -149,10 +140,8 @@ public class SensorDataServiceImpl implements ISensorDataService { PerceptionHandlerMap.perceptionHandlerMap.put(key, orDefault); } - - @Override - public void handlerPerceptionMap(){ + public void handlerPerceptionMap() { List publishList = new ArrayList<>(); List cancelList = new ArrayList<>(); List delList = new ArrayList<>(); @@ -163,7 +152,7 @@ public class SensorDataServiceImpl implements ISensorDataService { // 最后的接收时间大于 1 分钟 if (now - lastUpdateTime > 60 * 1000) { delList.add(key); - if (value.getAllReceiveTimes() > ALL_TIMES_THRESHOLD ) { + if (value.getAllReceiveTimes() > ALL_TIMES_THRESHOLD) { cancelList.add(value.getPerceptionParams()); } } else { @@ -194,9 +183,10 @@ public class SensorDataServiceImpl implements ISensorDataService { releaseLogReport.setReleaseStatus("发布成功"); List presetContentStyles = new ArrayList<>(); informationToBeReleasedList.forEach(i -> { - String[] split = StringUtils.split(i.getBoardSize(), "*"); +// String[] split = StringUtils.split(i.getBoardSize(), "*"); + String[] split = null; PresetContentStyle p = new PresetContentStyle(); - p.setFont(i.getFontStyle()); + p.setFont(i.getFontFamily()); p.setFontSize(i.getFontSize()); p.setFontColor(PrintColor.getBitColor(i.getFontColor())); p.setContent(i.getContent()); @@ -247,4 +237,11 @@ public class SensorDataServiceImpl implements ISensorDataService { releaseRecord.setCreatedBy(1); releaseRecordService.save(releaseRecord); } + + @Override + public void setPlanTypeNameIdMap() { + planTypeNameIdMap.clear(); + Map collect = planTypeService.list().stream().collect(Collectors.toMap(PlanType::getTypeName, PlanType::getId)); + planTypeNameIdMap.putAll(collect); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/sensor/task/ClearPerceptionTask.java b/ruoyi-system/src/main/java/com/ruoyi/sensor/task/ClearPerceptionTask.java index ba3e1204..b92f1420 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/sensor/task/ClearPerceptionTask.java +++ b/ruoyi-system/src/main/java/com/ruoyi/sensor/task/ClearPerceptionTask.java @@ -15,6 +15,7 @@ public class ClearPerceptionTask { private static final Logger log = LoggerFactory.getLogger(ClearPerceptionTask.class); public void clearPerception(){ + sensorDataService.setPlanTypeNameIdMap(); sensorDataService.handlerPerceptionMap(); log.info("handlerPerceptionMap 处理完了"); }