根据现场客户要求进行修改

This commit is contained in:
cdf
2026-07-06 10:54:23 +08:00
parent 2a702fd661
commit fa71d8406c
11 changed files with 428 additions and 45 deletions

View File

@@ -16,6 +16,7 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.event.file.pojo.dto.WaveDataDTO; import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.product.event.dataTransmit.DataSynchronization;
import com.njcn.product.event.devcie.config.PqlineCache; import com.njcn.product.event.devcie.config.PqlineCache;
import com.njcn.product.event.devcie.job.LineCacheJob; import com.njcn.product.event.devcie.job.LineCacheJob;
import com.njcn.product.event.devcie.mapper.PqLineMapper; import com.njcn.product.event.devcie.mapper.PqLineMapper;
@@ -104,7 +105,8 @@ public class EventGateController extends BaseController {
private final PqlineCache pqlineCache; private final PqlineCache pqlineCache;
private final SendMessageService messageService; private final SendMessageService messageService;
private final CleanEventService cleanEventService;
private final DataSynchronization dataSynchronization;
@GetMapping("/testSendMessage") @GetMapping("/testSendMessage")
@ApiOperation("接收远程推送的暂态事件") @ApiOperation("接收远程推送的暂态事件")
public HttpResult<Object> SendMessage(@RequestParam("startTime") String startTime,@RequestParam("endtTime") String endtTime) { public HttpResult<Object> SendMessage(@RequestParam("startTime") String startTime,@RequestParam("endtTime") String endtTime) {
@@ -112,6 +114,14 @@ public class EventGateController extends BaseController {
messageService.sendMessage(LocalDateTimeUtil.parse(startTime,DatePattern.NORM_DATETIME_PATTERN),LocalDateTimeUtil.parse(endtTime,DatePattern.NORM_DATETIME_PATTERN)); messageService.sendMessage(LocalDateTimeUtil.parse(startTime,DatePattern.NORM_DATETIME_PATTERN),LocalDateTimeUtil.parse(endtTime,DatePattern.NORM_DATETIME_PATTERN));
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@GetMapping("/testClean")
@ApiOperation("接收远程推送的暂态事件")
public HttpResult<Object> testClean() {
String methodDescribe = getMethodDescribe("testClean");
dataSynchronization.syncFail();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@OperateInfo @OperateInfo
@@ -419,6 +429,24 @@ public class EventGateController extends BaseController {
MessaeDTO result = eventGateService.messageGenerate(eventId); MessaeDTO result = eventGateService.messageGenerate(eventId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }
@OperateInfo
@PostMapping("/messageGenerateByIds")
@ApiOperation("暂降事件短信内容生成")
public HttpResult<MessaeDTO> messageGenerateByIds(@RequestParam List<String> eventIds) {
String methodDescribe = getMethodDescribe("messageGenerateByIds");
MessaeDTO result = eventGateService.messageGenerateByIds(eventIds);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo
@PostMapping("/msgGenerateByMsg")
@ApiOperation("根据故障短信内容生成暂降短信")
public HttpResult<MessaeDTO> msgGenerateByMsg(@RequestParam String msg) {
String methodDescribe = getMethodDescribe("msgGenerateByMsg");
MessaeDTO result = eventGateService.msgGenerateByMsg(msg);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo @OperateInfo
@PostMapping("/messageSend") @PostMapping("/messageSend")
@ApiOperation("短信发送") @ApiOperation("短信发送")
@@ -426,7 +454,12 @@ public class EventGateController extends BaseController {
String methodDescribe = getMethodDescribe("messageGenerate"); String methodDescribe = getMethodDescribe("messageGenerate");
List<MsgEventInfo> resultList = new ArrayList<>(); List<MsgEventInfo> resultList = new ArrayList<>();
List<SmsSendDTO.ItemInner> msgDTOList = new ArrayList<>(); List<SmsSendDTO.ItemInner> msgDTOList = new ArrayList<>();
for (PqsUser user : messaeDTO.getPqsUsers()) { List<PqsUser> allUsers = messaeDTO.getPqsUsers().values() // Collection<List<PqsUserSet>>
.stream() // 转为流
.filter(list -> list != null) // 过滤掉null的List可选
.flatMap(List::stream) // 将每个List拆开合并成一个流
.collect(Collectors.toList());
for (PqsUser user : allUsers) {
String msgId = IdUtil.simpleUUID(); String msgId = IdUtil.simpleUUID();
SmsSendDTO.ItemInner dto = new SmsSendDTO.ItemInner(); SmsSendDTO.ItemInner dto = new SmsSendDTO.ItemInner();
@@ -434,18 +467,20 @@ public class EventGateController extends BaseController {
dto.setTo(user.getPhone()); dto.setTo(user.getPhone());
dto.setCustomMsgID(msgId); dto.setCustomMsgID(msgId);
msgDTOList.add(dto); msgDTOList.add(dto);
for (String eventId :messaeDTO.getEventIds()){
MsgEventInfo msgEventInfo = new MsgEventInfo();
msgEventInfo.setMsgIndex(msgId);
msgEventInfo.setMsgContent(messaeDTO.getMessage());
msgEventInfo.setPhone(user.getPhone());
msgEventInfo.setUserId(user.getUserIndex());
msgEventInfo.setUserName(user.getName());
msgEventInfo.setIsHandle(0);
msgEventInfo.setSendResult(0);
msgEventInfo.setSendTime(LocalDateTime.now());
msgEventInfo.setEventIndex(eventId);
resultList.add(msgEventInfo);
}
MsgEventInfo msgEventInfo = new MsgEventInfo();
msgEventInfo.setMsgIndex(msgId);
msgEventInfo.setMsgContent(messaeDTO.getMessage());
msgEventInfo.setPhone(user.getPhone());
msgEventInfo.setUserId(user.getUserIndex());
msgEventInfo.setUserName(user.getName());
msgEventInfo.setIsHandle(0);
msgEventInfo.setSendResult(0);
msgEventInfo.setSendTime(LocalDateTime.now());
msgEventInfo.setEventIndex(messaeDTO.getEventId());
resultList.add(msgEventInfo);
} }
List<SmsResponseDTO.SmsItem> result = smsUtils.sendSmSToUser(msgDTOList); List<SmsResponseDTO.SmsItem> result = smsUtils.sendSmSToUser(msgDTOList);

View File

@@ -1,9 +1,11 @@
package com.njcn.product.event.transientes.pojo.dto; package com.njcn.product.event.transientes.pojo.dto;
import com.njcn.product.event.transientes.pojo.po.PqsUser; import com.njcn.product.event.transientes.pojo.po.PqsUser;
import com.njcn.product.event.transientes.pojo.po.PqsUserSet;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Description: * Description:
@@ -15,7 +17,8 @@ import java.util.List;
@Data @Data
public class MessaeDTO { public class MessaeDTO {
private String message; private String message;
private String eventId; private List<String> eventIds;
private List<PqsUser> pqsUsers; // private List<PqsUser> pqsUsers;
private Map<String, List<PqsUser>> pqsUsers;
} }

View File

@@ -43,6 +43,10 @@ public class LargeScreenCountParam extends BaseParam {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTDateime; private LocalDateTime endTDateime;
//是否过滤铭感客户默认是,1是0否
private String fiterSensitiveUser;
@ApiModelProperty(value = "字典树 对象大类") @ApiModelProperty(value = "字典树 对象大类")
private String bigObjType; private String bigObjType;

View File

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
@@ -106,6 +107,9 @@ public class PqsEventdetail {
@TableField(exist = false) @TableField(exist = false)
private String stationName; private String stationName;
@TableField(exist = false)
private List<String> consumerNameList;
@TableField(exist = false) @TableField(exist = false)
private String busBarName; private String busBarName;
} }

View File

@@ -0,0 +1,12 @@
package com.njcn.product.event.transientes.service;
/**
* Description:
* Date: 2026/07/01 上午 10:57【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface CleanEventService {
void cleanup();
}

View File

@@ -4,6 +4,8 @@ import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.product.event.transientes.pojo.dto.MessaeDTO; import com.njcn.product.event.transientes.pojo.dto.MessaeDTO;
import com.njcn.product.event.transientes.pojo.param.MonitorTerminalParam; import com.njcn.product.event.transientes.pojo.param.MonitorTerminalParam;
import java.util.List;
public interface EventGateService { public interface EventGateService {
@@ -15,4 +17,8 @@ public interface EventGateService {
WaveDataDTO getTransientAnalyseWave(MonitorTerminalParam param); WaveDataDTO getTransientAnalyseWave(MonitorTerminalParam param);
MessaeDTO messageGenerate(String eventId); MessaeDTO messageGenerate(String eventId);
MessaeDTO msgGenerateByMsg(String msg);
MessaeDTO messageGenerateByIds(List<String> eventIds);
} }

View File

@@ -0,0 +1,128 @@
package com.njcn.product.event.transientes.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
import com.njcn.product.event.config.RedisUtil;
import com.njcn.product.event.devcie.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.product.event.devcie.pojo.po.PqDevice;
import com.njcn.product.event.devcie.pojo.po.PqLine;
import com.njcn.product.event.devcie.pojo.po.PqLinedetail;
import com.njcn.product.event.transientes.pojo.po.PqsEventdetail;
import com.njcn.product.event.transientes.service.CleanEventService;
import com.njcn.product.event.transientes.service.PqsEventdetailService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* Description:
* Date: 2026/07/01 上午 10:57【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class CleanEventServiceImpl implements CleanEventService {
private final PqsEventdetailService pqsEventdetailService;
private final RedisUtil redisUtil;
private final static String NAME_KEY = "LineCache:";
@Value("${business.wavePath}")
private String WAVEPATH;
@Transactional(rollbackFor = Exception.class)
@Override
public void cleanup() {
log.info("开始执行 PQS_EVENTDETAIL 清理任务...");
LocalDateTime oneMonthAgo = LocalDateTime.now().minusMonths(1);
LocalDateTime twoMonthAgo = LocalDateTime.now().minusMonths(1).minusDays(5);
// 构建查询条件timeid 早于一个月前,且 eventvalue 在 [0.9, 0.98] 之间
LambdaQueryWrapper<PqsEventdetail> wrapper = new LambdaQueryWrapper<>();
wrapper.between(PqsEventdetail::getTimeid,twoMonthAgo, oneMonthAgo)
.ge(PqsEventdetail::getEventvalue, 0.9)
.le(PqsEventdetail::getEventvalue, 0.98);
// 一次性查询所有符合条件的记录(注意:若数据量极大,建议改为分页或分批处理)
List<PqsEventdetail> records = pqsEventdetailService.list(wrapper);
if (records == null || records.isEmpty()) {
log.info("没有符合条件的记录,清理任务结束");
return;
}
log.info("共查询到 {} 条待清理记录", records.size());
List<LedgerBaseInfoDTO> ledgerBaseInfoDTOS = (List<LedgerBaseInfoDTO>)redisUtil.getObjectByKey(NAME_KEY + StrUtil.DASHED+"LedgerBaseInfoDTO");
Map<Integer, LedgerBaseInfoDTO> LedgerBaseInfoDTOMap = ledgerBaseInfoDTOS.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
// 收集主键 ID 和删除文件
List<String> ids = new ArrayList<>(records.size());
for (PqsEventdetail record : records) {
ids.add(record.getEventdetailIndex());
Integer lineid = record.getLineid();
LedgerBaseInfoDTO ledgerBaseInfoDTO = LedgerBaseInfoDTOMap.get(lineid);
String waveName = record.getWavename();
String cfgPath, datPath,cfgPathLower,datPathLower;
if (StrUtil.isBlank(waveName)) {
continue;
}
cfgPath = WAVEPATH+"/"+ledgerBaseInfoDTO.getIp()+"/"+waveName+".CFG";
datPath = WAVEPATH+"/"+ledgerBaseInfoDTO.getIp()+"/"+waveName+".DAT";
cfgPathLower = WAVEPATH+"/"+ledgerBaseInfoDTO.getIp()+"/"+waveName+".cfg";
datPathLower = WAVEPATH+"/"+ledgerBaseInfoDTO.getIp()+"/"+waveName+".dat";
List<String> filePathList = new ArrayList<>();
filePathList.add(cfgPath);
filePathList.add(datPath);
filePathList.add(cfgPathLower);
filePathList.add(datPathLower);
deleteWaveFile(filePathList);
}
// 批量删除数据库记录
if (!ids.isEmpty()) {
boolean flag = pqsEventdetailService.removeByIds(ids);
}
log.info("PQS_EVENTDETAIL 清理任务完成");
}
/**
* 删除波形文件(若文件不存在则忽略)
*
* @param filePathList 文件路径(支持绝对或相对路径)
*/
private void deleteWaveFile(List<String> filePathList ) {
filePathList.forEach(filePath->{
if (filePath == null || filePath.trim().isEmpty()) {
return;
}
try {
Path path = Paths.get(filePath);
boolean deleted = Files.deleteIfExists(path);
if (deleted) {
log.debug("成功删除波形文件: {}", filePath);
} else {
log.warn("波形文件不存在,无法删除: {}", filePath);
}
} catch (IOException e) {
log.error("删除波形文件失败: {}", filePath, e);
}
});
}
}

View File

@@ -34,7 +34,10 @@ import org.springframework.stereotype.Service;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -110,7 +113,7 @@ public class EventGateServiceImpl implements EventGateService {
@Override @Override
public MessaeDTO messageGenerate(String eventId) { public MessaeDTO messageGenerate(String eventId) {
MessaeDTO messaeDTO = new MessaeDTO(); MessaeDTO messaeDTO = new MessaeDTO();
messaeDTO.setEventId(eventId); // messaeDTO.setEventId(eventId);
PqsEventdetail eventDetail = pqsEventdetailService.getById(eventId); PqsEventdetail eventDetail = pqsEventdetailService.getById(eventId);
Double eventvalue = eventDetail.getEventvalue(); Double eventvalue = eventDetail.getEventvalue();
BigDecimal eventvalueFormmat = new BigDecimal(eventvalue).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP); BigDecimal eventvalueFormmat = new BigDecimal(eventvalue).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
@@ -151,10 +154,156 @@ public class EventGateServiceImpl implements EventGateService {
} }
List<PqsUser> pqsUserList = pqsUserService.lambdaQuery().select(PqsUser::getUserIndex, PqsUser::getPhone, PqsUser::getName) List<PqsUser> pqsUserList = pqsUserService.lambdaQuery().select(PqsUser::getUserIndex, PqsUser::getPhone, PqsUser::getName)
.in(PqsUser::getUserIndex, pqsUserSetList.stream().map(PqsUserSet::getUserIndex).collect(Collectors.toList())).list(); .in(PqsUser::getUserIndex, pqsUserSetList.stream().map(PqsUserSet::getUserIndex).collect(Collectors.toList())).list();
messaeDTO.setPqsUsers(pqsUserList); // messaeDTO.setPqsUsers(pqsUserList);
return messaeDTO; return messaeDTO;
} }
@Override
public MessaeDTO msgGenerateByMsg(String msg) {
// 2. 解析为 LocalDateTime
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
// LocalDateTime extractedTime = LocalDateTime.parse(dateTimeStr, formatter);
//
// // 3. 计算前后各一分钟
// LocalDateTime startTime = extractedTime.minusMinutes(1);
// LocalDateTime endTime = extractedTime.plusMinutes(1);
// //获取敏感用户直供变电站名称
// List<PqUserLedgerPO> poList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().select(PqUserLedgerPO::getId, PqUserLedgerPO::getCustomerName,PqUserLedgerPO::getIsShow).eq(PqUserLedgerPO::getIsShow, 1));
// List<String> userIds = poList.stream().map(PqUserLedgerPO::getId).collect(Collectors.toList());
// List<PqUserLineAssPO> pqUserLineAssPOS = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getUserIndex, userIds));
// List<Integer> lineIds = pqUserLineAssPOS.stream().map(PqUserLineAssPO::getLineIndex).distinct().collect(Collectors.toList());
// LambdaQueryWrapper<PqsEventdetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
// lambdaQueryWrapper.in(PqsEventdetail::getLineid,lineIds).between(PqsEventdetail::getTimeid,startTime,endTime);
// List<PqsEventdetail> pqsEventdetails = pqsEventdetailService.list(lambdaQueryWrapper);
//
// if (CollUtil.isEmpty(pqsUserSetList)) {
// //当前事件未找到用户信息,判断为不需要发送短信用户
// throw new BusinessException("当前事件暂无发送短信用户信息");
// }
return null;
}
@Override
public MessaeDTO messageGenerateByIds(List<String> eventIds) {
MessaeDTO messaeDTO = new MessaeDTO();
List<PqsEventdetail> list = pqsEventdetailService.lambdaQuery().
in(PqsEventdetail::getEventdetailIndex, eventIds).orderByAsc(PqsEventdetail::getTimeid).list();
List<LedgerBaseInfoDTO> ledgerBaseInfoDTOS = (List<LedgerBaseInfoDTO>)redisUtil.getObjectByKey(NAME_KEY + StrUtil.DASHED+"LedgerBaseInfoDTO");
Map<Integer, LedgerBaseInfoDTO> LedgerBaseInfoDTOMap = ledgerBaseInfoDTOS.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
list.forEach(event->{
event.setBusBarName(LedgerBaseInfoDTOMap.get(event.getLineid()).getBusBarName());
event.setStationName(LedgerBaseInfoDTOMap.get(event.getLineid()).getStationName());
List<PqUserLineAssPO> assList = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().eq(PqUserLineAssPO::getLineIndex, event.getLineid()));
List<String> consumerNameList = new ArrayList<>();
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).eq(PqUserLedgerPO::getIsShow,1).in(PqUserLedgerPO::getId, userIds));
if(CollUtil.isNotEmpty(poList)){
consumerNameList= poList.stream().map(PqUserLedgerPO::getCustomerName).collect(Collectors.toList());
}
}
event.setConsumerNameList(consumerNameList);
});
Map<String, List<PqsEventdetail>> groupFilterNull = list.stream()
.filter(e -> e.getStationName() != null)
.collect(Collectors.groupingBy(PqsEventdetail::getStationName));
// AtomicInteger index = new AtomicInteger();
String eventString = groupFilterNull.entrySet().stream().map(entry -> {
String substationnName = entry.getKey(); // 例如 "110kV智芯变"
List<PqsEventdetail> value = entry.getValue();
StringBuilder sb = new StringBuilder();
if (value.size() == 1) {
BigDecimal eventvalue = new BigDecimal(value.get(0).getEventvalue()).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
BigDecimal persisttime = new BigDecimal(value.get(0).getPersisttime()).divide(new BigDecimal(1000)).setScale(3, RoundingMode.HALF_UP);
sb.append(substationnName).append(value.get(0).getBusBarName()).append("发生电压暂降,电压跌落至").append(eventvalue).append("%,持续时间:").append(persisttime).append("S");
String ConsumerName = value.stream().map(PqsEventdetail::getConsumerNameList).flatMap(List::stream).distinct().collect(Collectors.joining(","));
sb.append(",所带敏感用户为").append(ConsumerName);
} else {
Map<String, List<String>> BusNameMap = value.stream().map(PqsEventdetail::getBusBarName).distinct().collect(Collectors.groupingBy(EventGateServiceImpl::extractVoltage));
String allBusName = BusNameMap.entrySet().stream()
.sorted(Map.Entry.comparingByKey()) // 按电压等级排序110,220,500
.map(tempEntry -> {
String voltage = tempEntry.getKey(); // 例如 "110kV"
List<String> busNameList = tempEntry.getValue();
// 构建组内字符串:第一个保留全名,后续的去掉电压前缀
StringBuilder busName = new StringBuilder();
for (int i = 0; i < busNameList.size(); i++) {
String fullName = busNameList.get(i).replace("母线","");
if (i == 0) {
busName.append(fullName); // 第一个保留完整名称(含电压)
} else {
// 去掉电压前缀(例如 "10kV3B#母线" -> "3B#"
String pureName = fullName.startsWith(voltage)
? fullName.substring(voltage.length())
: fullName;
busName.append("").append(pureName.replace("母线",""));
}
}
return busName.toString();
})
.collect(Collectors.joining(","));
BigDecimal eventvalueMin = new BigDecimal(value.stream().mapToDouble(PqsEventdetail::getEventvalue).min().getAsDouble())
.multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
BigDecimal eventvalueMax = new BigDecimal(value.stream().mapToDouble(PqsEventdetail::getEventvalue).max().getAsDouble())
.multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
BigDecimal persisttimeMin = new BigDecimal(value.stream().mapToDouble(PqsEventdetail::getPersisttime).min().getAsDouble())
.divide(new BigDecimal(1000)).setScale(3, RoundingMode.HALF_UP);
BigDecimal persisttimeMax = new BigDecimal(value.stream().mapToDouble(PqsEventdetail::getPersisttime).max().getAsDouble())
.divide(new BigDecimal(1000)).setScale(3, RoundingMode.HALF_UP);
sb.append(substationnName).append(allBusName)
.append("母线电压跌落至").append(eventvalueMin).append("%—").append(eventvalueMax).append("%,持续时间:")
.append(persisttimeMin).append("S—").append(persisttimeMax).append("S");
String ConsumerName = value.stream().map(PqsEventdetail::getConsumerNameList).flatMap(List::stream).distinct().collect(Collectors.joining(","));
sb.append(",所带敏感用户为").append(ConsumerName);
}
return sb.toString();
}).collect(Collectors.joining(";"));
messaeDTO.setMessage(eventString);
List<Integer> lineIds = list.stream().map(PqsEventdetail::getLineid).distinct().collect(Collectors.toList());
List<PqsDeptsline> pqLineDept = pqsDeptslineService.lambdaQuery().in(PqsDeptsline::getLineIndex, lineIds).eq(PqsDeptsline::getSystype, sysTypeZt).list();
Set<String> deptIds = pqLineDept.stream().map(PqsDeptsline::getDeptsIndex).collect(Collectors.toSet());
Set<String> resultIds = getAllParentDeptIds(deptIds);
List<PqsUserSet> pqsUserSetList = pqsUsersetService.lambdaQuery().eq(PqsUserSet::getIsNotice, 1).in(PqsUserSet::getDeptsIndex, resultIds).list();
if (CollUtil.isEmpty(pqsUserSetList)) {
//当前事件未找到用户信息,判断为不需要发送短信用户
throw new BusinessException("当前事件暂无发送短信用户信息");
}
List<PqsUser> userMap = pqsUserService.lambdaQuery().select(PqsUser::getUserIndex, PqsUser::getPhone, PqsUser::getName)
.in(PqsUser::getUserIndex, pqsUserSetList.stream().map(PqsUserSet::getUserIndex).collect(Collectors.toList())).list();
Map<String, List<PqsUserSet>> collect = pqsUserSetList.stream().collect(Collectors.groupingBy(PqsUserSet::getDeptsIndex));
List<PqsDepts> allDeptList = pqsDeptsService.lambdaQuery().eq(PqsDepts::getState,1).list();
Map<String, PqsDepts> collect1 = allDeptList.stream().collect(Collectors.toMap(PqsDepts::getDeptsIndex, Function.identity()));
Map<String, List<PqsUser>> newMap = collect.entrySet().stream()
.collect(Collectors.toMap(
entry -> collect1.get(entry.getKey()).getDeptsname() , // 重新设置key逻辑
entry ->{
return userMap.stream().filter(temp->entry.getValue().stream().map(PqsUserSet::getUserIndex).collect(Collectors.toList()).contains(temp.getUserIndex())).collect(Collectors.toList());
}
));
messaeDTO.setEventIds(eventIds);
messaeDTO.setPqsUsers(newMap);
return messaeDTO;
}
private static String extractVoltage(String name) {
int kVIndex = name.indexOf("kV");
if (kVIndex == -1) {
log.info("存在台账"+name+"不符合命名规范");
throw new IllegalArgumentException("无法解析电压等级: " + name);
}
// 返回从开头到 "kV" 结束的部分(包含 "kV"
return name.substring(0, kVIndex + 2);
}
private boolean shouldSendSMS( Double value , Double time ) { private boolean shouldSendSMS( Double value , Double time ) {

View File

@@ -94,7 +94,7 @@ public class EventRightServiceImpl implements EventRightService {
Set<String> assUserIds = assList.stream() Set<String> assUserIds = assList.stream()
.map(PqUserLineAssPO::getUserIndex) .map(PqUserLineAssPO::getUserIndex)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
List<PqUserLedgerPO> userLedgers = getUserLedgers(new ArrayList<>(assUserIds),null,false); List<PqUserLedgerPO> userLedgers = getUserLedgers(new ArrayList<>(assUserIds),param,false);
if (CollUtil.isEmpty(userLedgers)) { if (CollUtil.isEmpty(userLedgers)) {
return result; return result;
} }
@@ -191,6 +191,9 @@ public class EventRightServiceImpl implements EventRightService {
}else { }else {
userWrapper.in(PqUserLedgerPO::getId, assUserIds); userWrapper.in(PqUserLedgerPO::getId, assUserIds);
} }
if(Objects.equals("1",param.getFiterSensitiveUser())){
userWrapper.eq(PqUserLedgerPO::getIsShow,1);
}
if(queryFlag){ if(queryFlag){
if(StrUtil.isNotBlank(param.getBigObjType())){ if(StrUtil.isNotBlank(param.getBigObjType())){
//对象大类不为空 //对象大类不为空
@@ -281,7 +284,9 @@ public class EventRightServiceImpl implements EventRightService {
treeMap.forEach((tree, obj) -> { treeMap.forEach((tree, obj) -> {
//获取对象大类的用户 //获取对象大类的用户
List<PqUserLedgerPO> oneList = userMap.get(obj.getId()); List<PqUserLedgerPO> oneList = userMap.get(obj.getId());
if(CollUtil.isEmpty(oneList)){
oneList = new ArrayList<>();
}
if (tree.equals(DicTreeEnum.BJ_USER.getCode())) { if (tree.equals(DicTreeEnum.BJ_USER.getCode())) {
Integer[] count = getEventCount(oneList, assList, eventdetailList,true); Integer[] count = getEventCount(oneList, assList, eventdetailList,true);
@@ -372,6 +377,8 @@ public class EventRightServiceImpl implements EventRightService {
if(CollUtil.isEmpty(deptLineIds)){ if(CollUtil.isEmpty(deptLineIds)){
return result; return result;
} }
//页面查询只显示敏感客户
param.setFiterSensitiveUser("1");
LambdaQueryWrapper<PqLine> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PqLine> queryWrapper = new LambdaQueryWrapper<>();
PqSubstation pqSubstation = null; PqSubstation pqSubstation = null;
@@ -555,6 +562,8 @@ public class EventRightServiceImpl implements EventRightService {
@Override @Override
public Page<PqUserLedgerPO> rightEventDevOpen(LargeScreenCountParam param) { public Page<PqUserLedgerPO> rightEventDevOpen(LargeScreenCountParam param) {
Page<PqUserLedgerPO> result = new Page<>(PageFactory.getPageNum(param),PageFactory.getPageSize(param)); Page<PqUserLedgerPO> result = new Page<>(PageFactory.getPageNum(param),PageFactory.getPageSize(param));
//页面查询只显示敏感客户
param.setFiterSensitiveUser("1");
List<Integer> lineIds = commGeneralService.getLineIdsByRedis(param.getDeptId()); List<Integer> lineIds = commGeneralService.getLineIdsByRedis(param.getDeptId());
if(CollUtil.isEmpty(lineIds)){ if(CollUtil.isEmpty(lineIds)){
return result; return result;
@@ -618,7 +627,9 @@ public class EventRightServiceImpl implements EventRightService {
}else { }else {
lambdaQueryWrapper.in(PqUserLedgerPO::getId,userIds); lambdaQueryWrapper.in(PqUserLedgerPO::getId,userIds);
} }
if(Objects.equals("1",param.getFiterSensitiveUser())){
lambdaQueryWrapper.eq(PqUserLedgerPO::getIsShow,1);
}
if(StrUtil.isNotBlank(param.getBigObjType())){ if(StrUtil.isNotBlank(param.getBigObjType())){
//对象大类不为空 //对象大类不为空
lambdaQueryWrapper.eq(PqUserLedgerPO::getBigObjType,param.getBigObjType()); lambdaQueryWrapper.eq(PqUserLedgerPO::getBigObjType,param.getBigObjType());
@@ -822,6 +833,8 @@ public class EventRightServiceImpl implements EventRightService {
long devCount = oneList.stream().filter(it->userLastIds.contains(it.getId())).count(); long devCount = oneList.stream().filter(it->userLastIds.contains(it.getId())).count();
count[1] = (int) devCount; count[1] = (int) devCount;
} }
}else {
oneList = new ArrayList<>();
} }
return count; return count;
} }
@@ -829,7 +842,8 @@ public class EventRightServiceImpl implements EventRightService {
@Override @Override
public UserLedgerStatisticVO userLedgerStatisticClone(LargeScreenCountParam param) { public UserLedgerStatisticVO userLedgerStatisticClone(LargeScreenCountParam param) {
UserLedgerStatisticVO result = new UserLedgerStatisticVO(); UserLedgerStatisticVO result = new UserLedgerStatisticVO();
//页面查询只显示敏感客户
param.setFiterSensitiveUser("1");
// 1. 获取字典树数据 // 1. 获取字典树数据
List<PqsDicTreePO> dicTreeList = getAllDicTrees(); List<PqsDicTreePO> dicTreeList = getAllDicTrees();
Map<String, PqsDicTreePO> treeMap = getDicTreeMap(dicTreeList); Map<String, PqsDicTreePO> treeMap = getDicTreeMap(dicTreeList);
@@ -840,6 +854,14 @@ public class EventRightServiceImpl implements EventRightService {
if (CollUtil.isEmpty(lineIds)) { if (CollUtil.isEmpty(lineIds)) {
return result; return result;
} }
if(Objects.equals("1",param.getFiterSensitiveUser())){
//查询重要敏感客户
List<PqUserLedgerPO> poList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().select(PqUserLedgerPO::getId, PqUserLedgerPO::getCustomerName,PqUserLedgerPO::getIsShow).eq(PqUserLedgerPO::getIsShow, 1));
List<String> userIds = poList.stream().map(PqUserLedgerPO::getId).collect(Collectors.toList());
List<PqUserLineAssPO> pqUserLineAssPOS = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getUserIndex, userIds));
List<Integer> templineIds = pqUserLineAssPOS.stream().map(PqUserLineAssPO::getLineIndex).distinct().collect(Collectors.toList());
lineIds.retainAll(templineIds);
}
// 3. 获取用户线路关联数据 // 3. 获取用户线路关联数据
List<PqUserLineAssPO> assList = getUserLineAssociations(lineIds); List<PqUserLineAssPO> assList = getUserLineAssociations(lineIds);
@@ -851,7 +873,7 @@ public class EventRightServiceImpl implements EventRightService {
Set<String> assUserIds = assList.stream() Set<String> assUserIds = assList.stream()
.map(PqUserLineAssPO::getUserIndex) .map(PqUserLineAssPO::getUserIndex)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
List<PqUserLedgerPO> userLedgers = getUserLedgers(new ArrayList<>(assUserIds),null,false); List<PqUserLedgerPO> userLedgers = getUserLedgers(new ArrayList<>(assUserIds),param,false);
if (CollUtil.isEmpty(userLedgers)) { if (CollUtil.isEmpty(userLedgers)) {
return result; return result;
} }
@@ -879,7 +901,8 @@ public class EventRightServiceImpl implements EventRightService {
if (CollUtil.isEmpty(lineIds)) { if (CollUtil.isEmpty(lineIds)) {
return result; return result;
} }
//页面查询只显示敏感客户
param.setFiterSensitiveUser("1");
LambdaQueryWrapper<PqLine> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PqLine> queryWrapper = new LambdaQueryWrapper<>();
PqSubstation pqSubstation = null; PqSubstation pqSubstation = null;
if(Objects.nonNull(param.getBdId())){ if(Objects.nonNull(param.getBdId())){
@@ -916,6 +939,9 @@ public class EventRightServiceImpl implements EventRightService {
LambdaQueryWrapper<PqUserLedgerPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PqUserLedgerPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.orderByAsc(PqUserLedgerPO::getSmallObjType,PqUserLedgerPO::getUpdateTime); lambdaQueryWrapper.orderByAsc(PqUserLedgerPO::getSmallObjType,PqUserLedgerPO::getUpdateTime);
if(Objects.equals("1",param.getFiterSensitiveUser())){
lambdaQueryWrapper.eq(PqUserLedgerPO::getIsShow,1);
}
if(StrUtil.isNotBlank(param.getBigObjType())){ if(StrUtil.isNotBlank(param.getBigObjType())){
//对象大类不为空 //对象大类不为空
lambdaQueryWrapper.eq(PqUserLedgerPO::getBigObjType,param.getBigObjType()); lambdaQueryWrapper.eq(PqUserLedgerPO::getBigObjType,param.getBigObjType());
@@ -953,16 +979,16 @@ public class EventRightServiceImpl implements EventRightService {
List<LedgerBaseInfoDTO> ledgerList = pqLineService.getBaseLedger(lineTemIds,null); List<LedgerBaseInfoDTO> ledgerList = pqLineService.getBaseLedger(lineTemIds,null);
List<PqsDeptsline> pqsDeptslineList = pqsDeptslineService.lambdaQuery().in(PqsDeptsline::getLineIndex,lineTemIds).eq(PqsDeptsline::getSystype,sysTypeZt).list(); List<PqsDeptsline> pqsDeptslineList = pqsDeptslineService.lambdaQuery().in(PqsDeptsline::getLineIndex,lineTemIds).eq(PqsDeptsline::getSystype,sysTypeZt).list();
Map<Integer,PqsDeptsline> deptLineMap = pqsDeptslineList.stream().collect(Collectors.toMap(PqsDeptsline::getLineIndex,dept->dept)); // Map<Integer,PqsDeptsline> deptLineMap = pqsDeptslineList.stream().collect(Collectors.toMap(PqsDeptsline::getLineIndex,dept->dept));
Map<Integer,List<PqsDeptsline>> deptLineMap = pqsDeptslineList.stream().collect(Collectors.groupingBy(PqsDeptsline::getLineIndex));
Map<Integer,String> deptTemMap = new HashMap<>(); Map<Integer,List<String>> deptTemMap = new HashMap<>();
List<PqsDepts> pqsDeptsList = pqsDeptsService.lambdaQuery().eq(PqsDepts::getState,1).list(); List<PqsDepts> pqsDeptsList = pqsDeptsService.lambdaQuery().eq(PqsDepts::getState,1).list();
Map<String,PqsDepts> deptMap = pqsDeptsList.stream().collect(Collectors.toMap(PqsDepts::getDeptsIndex,dept->dept)); Map<String,PqsDepts> deptMap = pqsDeptsList.stream().collect(Collectors.toMap(PqsDepts::getDeptsIndex,dept->dept));
deptLineMap.forEach((k,v)->{ deptLineMap.forEach((k,v)->{
deptTemMap.put(k,deptMap.get(v.getDeptsIndex()).getDeptsname()); deptTemMap.put(k,v.stream().map(PqsDeptsline::getDeptsIndex).map(deptMap::get).map(PqsDepts::getDeptsname).collect(Collectors.toList()));
}); });
Map<String,List<Integer>> assMap = assPOList.stream().collect(Collectors.groupingBy(PqUserLineAssPO::getUserIndex,Collectors.mapping(PqUserLineAssPO::getLineIndex,Collectors.toList()))); Map<String,List<Integer>> assMap = assPOList.stream().collect(Collectors.groupingBy(PqUserLineAssPO::getUserIndex,Collectors.mapping(PqUserLineAssPO::getLineIndex,Collectors.toList())));
for(PqUserLedgerPO po :page.getRecords()){ for(PqUserLedgerPO po :page.getRecords()){
@@ -972,7 +998,9 @@ public class EventRightServiceImpl implements EventRightService {
po.setGdName(temList.stream().map(LedgerBaseInfoDTO::getGdName).distinct().collect(Collectors.joining(";"))); po.setGdName(temList.stream().map(LedgerBaseInfoDTO::getGdName).distinct().collect(Collectors.joining(";")));
po.setStation(temList.stream().map(LedgerBaseInfoDTO::getStationName).distinct().collect(Collectors.joining(";"))); po.setStation(temList.stream().map(LedgerBaseInfoDTO::getStationName).distinct().collect(Collectors.joining(";")));
po.setInfo(temList.stream().map(it->it.getStationName()+"_"+it.getBusBarName()).distinct().collect(Collectors.joining(";"))); po.setInfo(temList.stream().map(it->it.getStationName()+"_"+it.getBusBarName()).distinct().collect(Collectors.joining(";")));
po.setDeptName(temList.stream().map(LedgerBaseInfoDTO::getLineId).distinct().map(deptTemMap::get).distinct().collect(Collectors.joining(";"))); // po.setDeptName(temList.stream().map(LedgerBaseInfoDTO::getLineId).distinct().map(deptTemMap::get).distinct().collect(Collectors.joining(";")));
po.setDeptName(temList.stream().map(LedgerBaseInfoDTO::getLineId).distinct().map(deptTemMap::get).flatMap(Collection::stream).distinct().collect(Collectors.joining(";")));
} }
} }

View File

@@ -1198,7 +1198,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
Page<PqsEventdetail> pqsEventdetailPage = new Page<>(largeScreenCountParam.getPageNum(), largeScreenCountParam.getPageSize()); Page<PqsEventdetail> pqsEventdetailPage = new Page<>(largeScreenCountParam.getPageNum(), largeScreenCountParam.getPageSize());
// LocalDateTime startTime = largeScreenCountParam.getStartTime().atStartOfDay(); // LocalDateTime startTime = largeScreenCountParam.getStartTime().atStartOfDay();
// LocalDateTime endTime = LocalDateTimeUtil.endOfDay(largeScreenCountParam.getEndTime().atStartOfDay()); // LocalDateTime endTime = LocalDateTimeUtil.endOfDay(largeScreenCountParam.getEndTime().atStartOfDay());
//页面查询只显示敏感客户
largeScreenCountParam.setFiterSensitiveUser("1");
List<Integer> deptslineIds = commGeneralService.getLineIdsByRedis(largeScreenCountParam.getDeptId()); List<Integer> deptslineIds = commGeneralService.getLineIdsByRedis(largeScreenCountParam.getDeptId());
List<LedgerBaseInfoDTO> ledgerList = new ArrayList<>(); List<LedgerBaseInfoDTO> ledgerList = new ArrayList<>();
@@ -1210,6 +1211,14 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
.gt(PqsEventdetail::getPersisttime, msgEventConfigService.getEventDuration()) .gt(PqsEventdetail::getPersisttime, msgEventConfigService.getEventDuration())
.le(PqsEventdetail::getEventvalue, msgEventConfigService.getEventValue()) .le(PqsEventdetail::getEventvalue, msgEventConfigService.getEventValue())
.orderByDesc(PqsEventdetail::getTimeid); .orderByDesc(PqsEventdetail::getTimeid);
if(Objects.equals("1",largeScreenCountParam.getFiterSensitiveUser())){
//查询重要敏感客户
List<PqUserLedgerPO> poList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().select(PqUserLedgerPO::getId, PqUserLedgerPO::getCustomerName,PqUserLedgerPO::getIsShow).eq(PqUserLedgerPO::getIsShow, 1));
List<String> userIds = poList.stream().map(PqUserLedgerPO::getId).collect(Collectors.toList());
List<PqUserLineAssPO> pqUserLineAssPOS = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getUserIndex, userIds));
List<Integer> lineIds = pqUserLineAssPOS.stream().map(PqUserLineAssPO::getLineIndex).distinct().collect(Collectors.toList());
deptslineIds.retainAll(lineIds);
}
if (Objects.nonNull(largeScreenCountParam.getEventtype())) { if (Objects.nonNull(largeScreenCountParam.getEventtype())) {
queryWrapper.eq(PqsEventdetail::getWavetype, largeScreenCountParam.getEventtype()); queryWrapper.eq(PqsEventdetail::getWavetype, largeScreenCountParam.getEventtype());
@@ -1549,10 +1558,10 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
Map<String, PqsDepts> pqsDeptsMap = pqsDeptsService.lambdaQuery().eq(PqsDepts::getState, 1).list().stream().collect(Collectors.toMap(PqsDepts::getDeptsIndex, Function.identity())); Map<String, PqsDepts> pqsDeptsMap = pqsDeptsService.lambdaQuery().eq(PqsDepts::getState, 1).list().stream().collect(Collectors.toMap(PqsDepts::getDeptsIndex, Function.identity()));
Map<Integer, PqsDeptsline> map = deptslineList.stream().collect(Collectors.toMap(PqsDeptsline::getLineIndex, Function.identity())); Map<Integer, List<PqsDeptsline>> map = deptslineList.stream().collect(Collectors.groupingBy(PqsDeptsline::getLineIndex));
Map<Integer, String> temMap = new HashMap<>(); Map<Integer, String> temMap = new HashMap<>();
map.forEach((lineId, deptline) -> { map.forEach((lineId, deptline) -> {
String deptName = pqsDeptsMap.get(deptline.getDeptsIndex()).getDeptsname(); String deptName = deptline.stream().map(PqsDeptsline::getDeptsIndex).map(pqsDeptsMap::get).map(PqsDepts::getDeptsname).collect(Collectors.joining(";"));
temMap.put(lineId, deptName); temMap.put(lineId, deptName);
}); });

View File

@@ -86,7 +86,7 @@ public class SendMessageServiceImpl implements SendMessageService {
List<String> successSendEventIds = msgEventInfos.stream().map(MsgEventInfo::getEventIndex).distinct().collect(Collectors.toList()); List<String> successSendEventIds = msgEventInfos.stream().map(MsgEventInfo::getEventIndex).distinct().collect(Collectors.toList());
pqsEventdetails = pqsEventdetails.stream() pqsEventdetails = pqsEventdetails.stream()
.filter(temp -> shouldSendSMS(temp.getEventvalue()*100, temp.getPersisttime()) && (!successSendEventIds.contains(temp.getEventdetailIndex()))) .filter(temp -> shouldSendSMS(temp.getEventvalue()*100, temp.getPersisttime(),temp.getWavetype()) && (!successSendEventIds.contains(temp.getEventdetailIndex())))
.collect(Collectors.toList()); .collect(Collectors.toList());
log.info("扫描到敏感客户暂态事件过滤后事件:"+pqsEventdetails.size()+""); log.info("扫描到敏感客户暂态事件过滤后事件:"+pqsEventdetails.size()+"");
@@ -344,23 +344,28 @@ public class SendMessageServiceImpl implements SendMessageService {
} }
private boolean shouldSendSMS( Double value , Double time ) { private boolean shouldSendSMS(Double value , Double time, Integer wavetype) {
if(wavetype==1){
// 条件1: 电压降至50%以下持续时间超过20ms
if (value < 50 && value>=10&& time >= 20) {
return true;
}
// 条件2: 电压降至50%—70%持续时间超过200ms
if (value >= 50 && value < 70 && time >= 200) {
return true;
}
// 条件1: 电压降至50%以下,持续时间超过20ms // 条件3: 电压降至70%—80%,持续时间超过500ms
if (value < 50 && time >= 20) { if (value >= 70 && value <= 80 && time >= 500) {
return true; return true;
}
} else if (wavetype==3) {
if (value < 10&& 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; return false;
} }