feat(自主发布逻辑):
This commit is contained in:
parent
21a17709ff
commit
9f2fd917ef
|
@ -18,7 +18,6 @@ public class AlertPlanAndPlanTypeDTO {
|
|||
|
||||
private String typeName;
|
||||
|
||||
|
||||
/**
|
||||
* 等级
|
||||
*/
|
||||
|
|
|
@ -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<String, Long> 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<PlanType> planTypeList = planTypeService.list();
|
||||
typeNameIDMap.putAll(planTypeList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
PlanType::getTypeName,
|
||||
PlanType::getId
|
||||
)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,9 @@ public interface IAlertPlanService extends MPJBaseService<AlertPlan> {
|
|||
|
||||
List<AlertPlanAndPlanTypeDTO> 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);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||
|
||||
public interface IBoardInfoService extends MPJBaseService<BoardInfo> {
|
||||
|
||||
BoardInfo getOneByIP(String ip);
|
||||
BoardInfoAndRoadDTO getOneByIP(String ip);
|
||||
|
||||
List<BoardInfoAndRoadDTO> listBoardInfoDTO(BoardInfo boardInfo);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||
|
||||
public interface IPresetContentService extends MPJBaseService<PresetContent> {
|
||||
|
||||
PresetContent getOneByContentAndBoardSize(String content, String boardSize, Integer type);
|
||||
PresetContent getOneByContentAndBoardSize(String content, String boardSize, Long type);
|
||||
|
||||
List<PresetContentDTO> listDTO(PresetContent presetContent);
|
||||
}
|
||||
|
|
|
@ -7,8 +7,5 @@ import com.ruoyi.board.domain.dto.ReleaseRecordAndPresetContentDTO;
|
|||
import java.util.List;
|
||||
|
||||
public interface IReleaseRecordService extends MPJBaseService<ReleaseRecord> {
|
||||
|
||||
List<ReleaseRecordAndPresetContentDTO> listLatest2minRecordDtoByBoardId(Integer boardId);
|
||||
|
||||
List<ReleaseRecord> listLatest2minRecordByBoardId(Integer boardId);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class AlertPlanServiceImpl extends MPJBaseServiceImpl<AlertPlanMapper, Al
|
|||
}
|
||||
|
||||
@Override
|
||||
public AlertPlan getOneByTypeAndValue(Integer planType, Double value) {
|
||||
public AlertPlan getOneByTypeAndValue(Long planType, Double value) {
|
||||
if (planType < 0) {
|
||||
return null;
|
||||
}
|
||||
|
@ -56,4 +56,12 @@ public class AlertPlanServiceImpl extends MPJBaseServiceImpl<AlertPlanMapper, Al
|
|||
return selectJoinOne(AlertPlanAndPlanTypeDTO.class, eq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlertPlan getOneByPresetContentId(Integer id, Integer typeId) {
|
||||
LambdaQueryWrapper<AlertPlan> alertPlanLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
alertPlanLambdaQueryWrapper.eq(AlertPlan::getPresetContentId, id);
|
||||
alertPlanLambdaQueryWrapper.eq(AlertPlan::getType, typeId);
|
||||
return getOne(alertPlanLambdaQueryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<BoardInfoMapper, BoardInfo> implements IBoardInfoService {
|
||||
|
||||
@Override
|
||||
public BoardInfo getOneByIP(String ip) {
|
||||
LambdaQueryWrapper<BoardInfo> boardInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
boardInfoLambdaQueryWrapper.eq(BoardInfo::getBoardIp, ip);
|
||||
return getOne(boardInfoLambdaQueryWrapper);
|
||||
public BoardInfoAndRoadDTO getOneByIP(String ip) {
|
||||
MPJLambdaWrapper<BoardInfo> eq = condition()
|
||||
.eq(StringUtils.isNotEmpty(ip), BoardInfo::getBoardIp, ip);
|
||||
return selectJoinOne(BoardInfoAndRoadDTO.class, eq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BoardInfoAndRoadDTO> listBoardInfoDTO(BoardInfo boardInfo) {
|
||||
MPJLambdaWrapper<BoardInfo> eq = new MPJLambdaWrapper<BoardInfo>()
|
||||
MPJLambdaWrapper<BoardInfo> 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<BoardInfo> condition() {
|
||||
return new MPJLambdaWrapper<BoardInfo>()
|
||||
.selectAll(BoardInfo.class)
|
||||
.select(RoadGroup::getRoadName)
|
||||
.selectAs(BoardType::getName, "board_size_name")
|
||||
|
@ -36,10 +44,6 @@ public class BoardInfoServiceImpl extends MPJBaseServiceImpl<BoardInfoMapper, Bo
|
|||
.selectAs(BoardProtocol::getProtocol, "board_protocol_name")
|
||||
.leftJoin(RoadGroup.class, RoadGroup::getId, BoardInfo::getBoardRoadSection)
|
||||
.leftJoin(BoardType.class, BoardType::getId, BoardInfo::getBoardSizeType)
|
||||
.leftJoin(BoardProtocol.class, BoardProtocol::getId, BoardInfo::getBoardBrandProtocol)
|
||||
.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);
|
||||
.leftJoin(BoardProtocol.class, BoardProtocol::getId, BoardInfo::getBoardBrandProtocol);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.List;
|
|||
@Service
|
||||
public class PresetContentServiceImpl extends MPJBaseServiceImpl<PresetContentMapper, PresetContent> implements IPresetContentService {
|
||||
@Override
|
||||
public PresetContent getOneByContentAndBoardSize(String content, String boardSize, Integer type) {
|
||||
public PresetContent getOneByContentAndBoardSize(String content, String boardSize, Long type) {
|
||||
LambdaQueryWrapper<PresetContent> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper
|
||||
.eq(PresetContent::getContent, content)
|
||||
|
|
|
@ -20,23 +20,9 @@ import java.util.List;
|
|||
public class ReleaseRecordServiceImpl extends MPJBaseServiceImpl<ReleaseRecordMapper, ReleaseRecord> implements IReleaseRecordService {
|
||||
private static final Logger log = LoggerFactory.getLogger(ReleaseRecordServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public List<ReleaseRecordAndPresetContentDTO> listLatest2minRecordDtoByBoardId(Integer boardId) {
|
||||
Date before2min = new Date(System.currentTimeMillis() - 30 * 60 * 1000);
|
||||
return selectJoinList(ReleaseRecordAndPresetContentDTO.class,
|
||||
new MPJLambdaWrapper<ReleaseRecord>()
|
||||
.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<ReleaseRecord> listLatest2minRecordByBoardId(Integer boardId) {
|
||||
Date before2min = new Date(System.currentTimeMillis() - 30 * 60 * 1000);
|
||||
Date before2min = new Date(System.currentTimeMillis() - 2 * 60 * 1000);
|
||||
LambdaQueryWrapper<ReleaseRecord> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ReleaseRecord::getBoardId, boardId)
|
||||
.gt(ReleaseRecord::getCreateTime, before2min);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<PresetContent> presetContentList, BoardInfo boardInfo) {
|
||||
private String createTextItem(List<PresetContent> 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<AreaItem> 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<PresetContent> presetContentList) {
|
||||
public void publishContent(BoardInfoAndRoadDTO boardInfo, List<PresetContent> presetContentList) {
|
||||
String path = createTextItem(presetContentList, boardInfo);
|
||||
uploadAndStartPlayList(path);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<PresetContent> presetContentList);
|
||||
void publishContent(BoardInfoAndRoadDTO boardInfo, List<PresetContent> presetContentList);
|
||||
|
||||
default void publishInformation(BoardInfo boardInfo, List<PresetContent> presetContentList){
|
||||
default void publishInformation(BoardInfoAndRoadDTO boardInfo, List<PresetContent> presetContentList){
|
||||
// 登录
|
||||
loginDevice(boardInfo);
|
||||
// 发布
|
||||
|
|
|
@ -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<IProtocolService> protocolServiceList;
|
||||
|
||||
public void contentPublish(BoardInfo boardInfo, List<PresetContent> presetContentList) {
|
||||
IProtocolService iProtocolService = protocolServiceList.stream().filter(i -> i.protocolSupport(boardInfo.getBoardCommunicationProtocol())).findFirst().orElse(null);
|
||||
public void contentPublish(BoardInfoAndRoadDTO boardInfo, List<PresetContent> presetContentList) {
|
||||
IProtocolService iProtocolService = protocolServiceList.stream().filter(i -> i.protocolSupport(boardInfo.getBoardProtocolName())).findFirst().orElse(null);
|
||||
if (iProtocolService ==null) {
|
||||
log.error("协议不支持");
|
||||
return;
|
||||
|
|
|
@ -9,4 +9,6 @@ public interface ISensorDataService {
|
|||
void putPerceptionParamsToMap(PerceptionParams perceptionParams);
|
||||
|
||||
void handlerPerceptionMap();
|
||||
|
||||
void setPlanTypeNameIdMap();
|
||||
}
|
||||
|
|
|
@ -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<String, Long> 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<Integer> presetContentIdList = releaseRecordList.stream().map(ReleaseRecord::getPresetContentId).collect(Collectors.toList());
|
||||
Set<Integer> presetContentIdList = releaseRecordList.stream().map(ReleaseRecord::getPresetContentId).collect(Collectors.toSet());
|
||||
List<PresetContent> 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<PerceptionParams> publishList = new ArrayList<>();
|
||||
List<PerceptionParams> cancelList = new ArrayList<>();
|
||||
List<String> 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<PresetContentStyle> 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<String, Long> collect = planTypeService.list().stream().collect(Collectors.toMap(PlanType::getTypeName, PlanType::getId));
|
||||
planTypeNameIdMap.putAll(collect);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 处理完了");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue