4 Commits

Author SHA1 Message Date
hzj
be6628fe35 根据北京公司要求修改暂降系统手机短信通知相关策略。 2026-05-25 14:52:28 +08:00
hzj
6c7ca8eb46 波形添加大小写适配 2026-05-14 10:53:50 +08:00
hzj
5dff7c6ff8 波形添加大小写适配 2026-05-13 09:06:07 +08:00
a96fce38be 测试事件bug修改 2026-03-03 13:43:56 +08:00
3 changed files with 112 additions and 42 deletions

View File

@@ -54,17 +54,31 @@ public class EventGateServiceImpl implements EventGateService {
String lineid = eventDetail.getLineId();
LedgerBaseInfo pqLine = ledgerScaleMapper.getLedgerBaseInfo(Stream.of(lineid).collect(Collectors.toList())).get(0);
String waveName = eventDetail.getWavePath();
String cfgPath, datPath;
String cfgPath, datPath,cfgPath1,datPath1;
InputStream cfgStream,datStream;
if (StrUtil.isBlank(waveName)) {
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
}
cfgPath = generalInfo.getBusinessWavePath()+ File.separator+pqLine.getIp()+"/"+waveName+".CFG";
datPath = generalInfo.getBusinessWavePath()+ File.separator+pqLine.getIp()+"/"+waveName+".DAT";
log.info("本地磁盘波形文件路径----" + cfgPath);
InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath);
InputStream datStream = waveFileComponent.getFileInputStreamByFilePath(datPath);
try {
cfgPath = generalInfo.getBusinessWavePath()+ File.separator+pqLine.getIp()+"/"+waveName+".CFG";
datPath = generalInfo.getBusinessWavePath()+ File.separator+pqLine.getIp()+"/"+waveName+".DAT";
cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath);
datStream = waveFileComponent.getFileInputStreamByFilePath(datPath);
log.info("本地磁盘波形文件路径----" + cfgPath);
}catch (Exception e){
cfgPath1 = generalInfo.getBusinessWavePath()+ File.separator+pqLine.getIp()+"/"+waveName+".cfg";
datPath1 = generalInfo.getBusinessWavePath()+ File.separator+pqLine.getIp()+"/"+waveName+".dat";
cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath1);
datStream = waveFileComponent.getFileInputStreamByFilePath(datPath1);
}
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
}
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);

View File

@@ -1,6 +1,7 @@
package com.njcn.product.event.transientes.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
@@ -116,35 +117,56 @@ public class EventGateController extends BaseController {
&& Float.parseFloat(jsonObject.get("eventvalue").toString()) <= msgEventConfigService.getEventValue()
&& (Float.parseFloat(jsonObject.get("persisttime").toString()) * 1000) >= msgEventConfigService.getEventDuration()) {
//过滤重要暂降事件
//F47过滤
float eventvalue = Float.parseFloat(jsonObject.get("eventvalue").toString());
float persisttime = Float.parseFloat(jsonObject.get("persisttime").toString()) * 1000;
if(shouldSendSMS(eventvalue,persisttime)){
Integer lineId = Integer.valueOf(jsonObject.get("lineid").toString());
List<PqUserLineAssPO> assList = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().eq(PqUserLineAssPO::getLineIndex, lineId));
jsonObject.set("persisttime",new BigDecimal(jsonObject.get("persisttime").toString()).setScale(3,RoundingMode.HALF_UP).toString());
Integer lineId = Integer.valueOf(jsonObject.get("lineid").toString());
List<PqUserLineAssPO> assList = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().eq(PqUserLineAssPO::getLineIndex, lineId));
String str ;
if (CollUtil.isNotEmpty(assList)) {
List<String> userIds = assList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
List<PqUserLedgerPO> poList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().select(PqUserLedgerPO::getId, PqUserLedgerPO::getCustomerName,PqUserLedgerPO::getIsShow).in(PqUserLedgerPO::getId, userIds));
List<PqUserLedgerPO> isShowUser = poList.stream().filter(temp -> temp.getIsShow() == 1).collect(Collectors.toList());
List<PqUserLedgerPO> noShowUser = poList.stream().filter(temp -> temp.getIsShow() != 1).collect(Collectors.toList());
String strUser="" ;
if(CollectionUtil.isEmpty(isShowUser)){
strUser =strUser+"影响集成电路敏感用户:无;";
}else {
String sensitiveUser = isShowUser.stream().map(PqUserLedgerPO::getCustomerName).collect(Collectors.joining(";"));
strUser =strUser+"影响集成电路敏感用户:"+sensitiveUser+";";
}
if(CollectionUtil.isEmpty(noShowUser)){
strUser =strUser+"影响其他用户:无;";
}else {
String sensitiveUser = noShowUser.stream().map(PqUserLedgerPO::getCustomerName).collect(Collectors.joining(";"));
strUser =strUser+"影响其他用户:"+sensitiveUser+";";
}
str = strUser;
} else {
str = "/";
}
List<PqsDepts> deptsList = (List<PqsDepts>) redisUtil.getObjectByKey(REDIS_DEPT_INDEX + StrUtil.DASHED + "AllDept");
Map<String, PqsDepts> deptsMap = deptsList.stream().collect(Collectors.toMap(PqsDepts::getDeptsIndex, dept -> dept));
List<PqsDeptsline> deptslineList = pqsDeptslineService.lambdaQuery().eq(PqsDeptsline::getLineIndex, lineId).list();
List<String> deptIds = deptslineList.stream().map(PqsDeptsline::getDeptsIndex).collect(Collectors.toList());
Set<String> set = getAllParentIdsWithChildrenBatch(deptIds, deptsMap);
jsonObject.putOpt("objName", str);
jsonObject.putOpt("dept", String.join(StrUtil.COMMA, set));
webSocketServer.sendMessageToAll(jsonObject.toString());
//针对前置推送的暂降事件进行短信发送功能
smsTaskExecutor.execute(() -> {
sendMessage(jsonObject, str);
});
String str;
if (CollUtil.isNotEmpty(assList)) {
List<String> userIds = assList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
List<PqUserLedgerPO> poList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().select(PqUserLedgerPO::getId, PqUserLedgerPO::getCustomerName).in(PqUserLedgerPO::getId, userIds));
str = poList.stream().map(PqUserLedgerPO::getCustomerName).collect(Collectors.joining(";"));
} else {
str = "/";
}
List<PqsDepts> deptsList = (List<PqsDepts>) redisUtil.getObjectByKey(REDIS_DEPT_INDEX + StrUtil.DASHED + "AllDept");
Map<String, PqsDepts> deptsMap = deptsList.stream().collect(Collectors.toMap(PqsDepts::getDeptsIndex, dept -> dept));
List<PqsDeptsline> deptslineList = pqsDeptslineService.lambdaQuery().eq(PqsDeptsline::getLineIndex, lineId).list();
List<String> deptIds = deptslineList.stream().map(PqsDeptsline::getDeptsIndex).collect(Collectors.toList());
Set<String> set = getAllParentIdsWithChildrenBatch(deptIds, deptsMap);
jsonObject.putOpt("objName", str);
jsonObject.putOpt("dept", String.join(StrUtil.COMMA, set));
webSocketServer.sendMessageToAll(jsonObject.toString());
//针对前置推送的暂降事件进行短信发送功能
smsTaskExecutor.execute(() -> {
sendMessage(jsonObject, str);
});
}
} catch (Exception e) {
@@ -154,6 +176,27 @@ public class EventGateController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
private boolean shouldSendSMS( Float value , Float time ) {
// 条件1: 电压降至50%以下持续时间超过20ms
if (value < 0.5 && time >= 20) {
return true;
}
// 条件2: 电压降至50%—70%持续时间超过200ms
if (value >= 50 && value < 70 && time >= 200) {
return true;
}
// 条件3: 电压降至70%—80%持续时间超过500ms
if (value >= 70 && value < 80 && time >= 500) {
return true;
}
return false;
}
public Set<String> getAllParentIdsRecursive(String deptId, Map<String, PqsDepts> deptMap, Set<String> result) {
if (deptId == null || result.contains(deptId)) {
return result;
@@ -187,8 +230,12 @@ public class EventGateController extends BaseController {
try {
//下面一行代码正式环境需要放开
jsonObject = test();
List<PqsDepts> deptsList = (List<PqsDepts>) redisUtil.getObjectByKey(REDIS_DEPT_INDEX + StrUtil.DASHED + "AllDept");
List<String> deptIds = deptsList.stream().map(PqsDepts::getDeptsIndex).distinct().collect(Collectors.toList());
jsonObject.putOpt("dept", String.join(StrUtil.COMMA,deptIds));
if (msgEventConfigService.getEventType().contains(jsonObject.get("wavetype").toString()) && Float.parseFloat(jsonObject.get("eventvalue").toString()) <= msgEventConfigService.getEventValue()) {
log.info("122345678788999999----------测试发送数据成功: {}",jsonObject);
webSocketServer.sendMessageToAll(jsonObject.toString());
//开始发送短信
@@ -232,8 +279,19 @@ public class EventGateController extends BaseController {
//以下部分为测试数据后续删除
List<PqLine> pqLineList = pqLineMapper.selectList(new LambdaQueryWrapper<>());
List<Integer> lineList = pqLineList.stream().map(PqLine::getLineIndex).collect(Collectors.toList());
List<LedgerBaseInfoDTO> baseInfoDTOList = pqLineMapper.getBaseLineInfo(lineList);
Map<Integer, LedgerBaseInfoDTO> map = baseInfoDTOList.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
List<LedgerBaseInfoDTO> ledgerBaseInfoDTOS = new ArrayList<>();
if(lineList.size()>1000){
List<List<Integer>> listIds = CollUtil.split(lineList,1000);
for(List<Integer> itemIds : listIds){
List<LedgerBaseInfoDTO> temp =pqLineMapper.getBaseLineInfo(itemIds);
ledgerBaseInfoDTOS.addAll(temp);
}
}else {
List<LedgerBaseInfoDTO> temp =pqLineMapper.getBaseLineInfo(lineList);
ledgerBaseInfoDTOS.addAll(temp);
}
Map<Integer, LedgerBaseInfoDTO> map = ledgerBaseInfoDTOS.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
Random random = new Random();
Integer lineId = lineList.get(random.nextInt(lineList.size()));
@@ -355,15 +413,13 @@ public class EventGateController extends BaseController {
if (CollUtil.isNotEmpty(poList)) {
StringBuilder stringBuilder = new StringBuilder(jsonObject.get("timeid").toString());
String busName = jsonObject.containsKey("busname")? "_"+jsonObject.get("busname").toString():"";
BigDecimal bigDecimal = new BigDecimal(jsonObject.get("eventvalue").toString()).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
stringBuilder.append(".").append(jsonObject.get("ms").toString()).append(",").append(jsonObject.get("bdname").toString()).append("_").append(jsonObject.get("busname").toString()).append("_").append(jsonObject.get("pointname").toString())
.append("发生电压暂降事件,事件残余电压").append(bigDecimal).append("%,持续时间:").append(jsonObject.get("persisttime").toString()).append("S;影响用户:");
stringBuilder.append(".").append(jsonObject.get("ms").toString()).append(",").append(jsonObject.get("bdname").toString()).append(busName)
// .append("_").append(jsonObject.get("pointname").toString())
.append("发生电压暂降事件,事件残余电压").append(bigDecimal).append("%,持续时间:").append(jsonObject.get("persisttime").toString()).append("S;");
stringBuilder.append(objStr);
//TODO 临时处理,后面需要用上
String message;
if (stringBuilder.length() > 500) {
message = stringBuilder.substring(0, 490).concat(";详情请登录电压暂降监测平台查看。");

View File

@@ -40,10 +40,10 @@ business:
wavePath: D://Comtrade
targetPath: /pqmonitor
exportBaseDir: D://exportComtrade
eventCronExpression: 0 0/10 * * * ?
eventCronExpression: 0 0/2 * * * ?
failCronExpression: 0 5/10 * * * ?
userCronExpression: 0 5 1 * * ?
syncinterval: 10
syncinterval: 2
failsyncinterval: 1440
#wavePath: /usr/local/comtrade
#处理临时数据