根据北京公司要求修改暂降系统手机短信通知相关策略。

This commit is contained in:
hzj
2026-05-25 14:52:28 +08:00
parent 6c7ca8eb46
commit be6628fe35
2 changed files with 73 additions and 29 deletions

View File

@@ -1,6 +1,7 @@
package com.njcn.product.event.transientes.controller; package com.njcn.product.event.transientes.controller;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.date.LocalDateTimeUtil;
@@ -116,16 +117,34 @@ public class EventGateController extends BaseController {
&& Float.parseFloat(jsonObject.get("eventvalue").toString()) <= msgEventConfigService.getEventValue() && Float.parseFloat(jsonObject.get("eventvalue").toString()) <= msgEventConfigService.getEventValue()
&& (Float.parseFloat(jsonObject.get("persisttime").toString()) * 1000) >= msgEventConfigService.getEventDuration()) { && (Float.parseFloat(jsonObject.get("persisttime").toString()) * 1000) >= msgEventConfigService.getEventDuration()) {
//过滤重要暂降事件 //过滤重要暂降事件
//F47过滤
jsonObject.set("persisttime",new BigDecimal(jsonObject.get("persisttime").toString()).setScale(3,RoundingMode.HALF_UP).toString()); 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()); Integer lineId = Integer.valueOf(jsonObject.get("lineid").toString());
List<PqUserLineAssPO> assList = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().eq(PqUserLineAssPO::getLineIndex, lineId)); List<PqUserLineAssPO> assList = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().eq(PqUserLineAssPO::getLineIndex, lineId));
String str; String str ;
if (CollUtil.isNotEmpty(assList)) { if (CollUtil.isNotEmpty(assList)) {
List<String> userIds = assList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList()); 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)); List<PqUserLedgerPO> poList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().select(PqUserLedgerPO::getId, PqUserLedgerPO::getCustomerName,PqUserLedgerPO::getIsShow).in(PqUserLedgerPO::getId, userIds));
str = poList.stream().map(PqUserLedgerPO::getCustomerName).collect(Collectors.joining(";")); 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 { } else {
str = "/"; str = "/";
} }
@@ -145,6 +164,9 @@ public class EventGateController extends BaseController {
smsTaskExecutor.execute(() -> { smsTaskExecutor.execute(() -> {
sendMessage(jsonObject, str); sendMessage(jsonObject, str);
}); });
}
} }
} catch (Exception e) { } catch (Exception e) {
@@ -154,6 +176,27 @@ public class EventGateController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); 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) { public Set<String> getAllParentIdsRecursive(String deptId, Map<String, PqsDepts> deptMap, Set<String> result) {
if (deptId == null || result.contains(deptId)) { if (deptId == null || result.contains(deptId)) {
return result; return result;
@@ -372,8 +415,9 @@ public class EventGateController extends BaseController {
StringBuilder stringBuilder = new StringBuilder(jsonObject.get("timeid").toString()); StringBuilder stringBuilder = new StringBuilder(jsonObject.get("timeid").toString());
String busName = jsonObject.containsKey("busname")? "_"+jsonObject.get("busname").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); 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(busName).append("_").append(jsonObject.get("pointname").toString()) stringBuilder.append(".").append(jsonObject.get("ms").toString()).append(",").append(jsonObject.get("bdname").toString()).append(busName)
.append("发生电压暂降事件,事件残余电压").append(bigDecimal).append("%,持续时间:").append(jsonObject.get("persisttime").toString()).append("S;影响用户:"); // .append("_").append(jsonObject.get("pointname").toString())
.append("发生电压暂降事件,事件残余电压").append(bigDecimal).append("%,持续时间:").append(jsonObject.get("persisttime").toString()).append("S;");
stringBuilder.append(objStr); stringBuilder.append(objStr);
String message; String message;

View File

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