波形文件
This commit is contained in:
@@ -64,13 +64,9 @@
|
||||
<version>21.6.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
<groupId>com.oracle.database.nls</groupId>
|
||||
|
||||
<artifactId>orai18n</artifactId>
|
||||
|
||||
<version>21.1.0.0</version> <!-- 版本号需要与你的ojdbc版本匹配 -->
|
||||
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Security -->
|
||||
@@ -98,6 +94,25 @@
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-event</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-echarts</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
package com.njcn.gather.event.transientes.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
||||
import com.njcn.gather.event.devcie.mapper.PqLineMapper;
|
||||
import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO;
|
||||
import com.njcn.gather.event.devcie.pojo.po.PqLine;
|
||||
import com.njcn.gather.event.devcie.pojo.po.PqsDeptsline;
|
||||
import com.njcn.gather.event.devcie.service.PqsDeptslineService;
|
||||
import com.njcn.gather.event.transientes.pojo.param.MonitorTerminalParam;
|
||||
import com.njcn.gather.event.transientes.pojo.po.PqsDepts;
|
||||
import com.njcn.gather.event.transientes.pojo.po.PqsUser;
|
||||
import com.njcn.gather.event.transientes.pojo.po.PqsUserSet;
|
||||
import com.njcn.gather.event.transientes.service.PqsDeptsService;
|
||||
import com.njcn.gather.event.transientes.service.PqsUserService;
|
||||
import com.njcn.gather.event.transientes.service.PqsUsersetService;
|
||||
import com.njcn.gather.event.transientes.websocket.WebSocketServer;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
@@ -17,6 +30,14 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-06-23
|
||||
@@ -35,14 +56,43 @@ public class EventGateController extends BaseController {
|
||||
|
||||
private final PqsDeptslineService pqsDeptslineService;
|
||||
|
||||
private final PqsDeptsService pqsDeptsService;
|
||||
|
||||
private final PqsUserService pqsUserService;
|
||||
|
||||
private final PqsUsersetService pqsUsersetService;
|
||||
|
||||
private final PqLineMapper pqLineMapper;
|
||||
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/eventMsg")
|
||||
@ApiOperation("接收远程推送的暂态事件")
|
||||
@ApiImplicitParam(name = "eventMsg", value = "暂态事件json字符", required = true)
|
||||
public HttpResult<Object> eventMsg(@RequestParam("msg") String msg) {
|
||||
System.out.println(msg);
|
||||
String methodDescribe = getMethodDescribe("eventMsg");
|
||||
webSocketServer.sendMessageToAll(msg);
|
||||
JSONObject jsonObject;
|
||||
try {
|
||||
jsonObject = new JSONObject(msg);
|
||||
webSocketServer.sendMessageToAll(msg);
|
||||
|
||||
//开始发送短信
|
||||
sendMessage(jsonObject);
|
||||
}catch (Exception e){
|
||||
log.error("暂降json格式异常!{}",e.getMessage());
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getTransientAnalyseWave")
|
||||
@ApiOperation("暂态事件波形分析")
|
||||
public HttpResult<WaveDataDTO> getTransientAnalyseWave(@RequestBody MonitorTerminalParam param){
|
||||
String methodDescribe = getMethodDescribe("getTransientAnalyseWave");
|
||||
// WaveDataDTO wave = transientService.getTransientAnalyseWave(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -51,10 +101,59 @@ public class EventGateController extends BaseController {
|
||||
|
||||
private void sendMessage(JSONObject jsonObject){
|
||||
Integer lineId = Integer.valueOf(jsonObject.get("lineid").toString());
|
||||
List<PqsDeptsline> pqLineDept = pqsDeptslineService.lambdaQuery().eq(PqsDeptsline::getLineIndex,lineId).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)){
|
||||
//当前事件未找到用户信息,判断为不需要发送短信用户
|
||||
return;
|
||||
}
|
||||
List<PqsUser> pqsUserList = pqsUserService.lambdaQuery().select(PqsUser::getUserIndex).in(PqsUser::getUserIndex,pqsUserSetList.stream().map(PqsUserSet::getUserIndex).collect(Collectors.toList())).list();
|
||||
List<String> userIds = pqsUserList.stream().map(PqsUser::getUserIndex).collect(Collectors.toList());
|
||||
List<PqsUserSet> poList = pqsUserSetList.stream().filter(it->userIds.contains(it.getUserIndex())).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(poList)){
|
||||
StringBuilder stringBuilder = new StringBuilder(jsonObject.get("timeid").toString());
|
||||
List<LedgerBaseInfoDTO> list = pqLineMapper.getBaseLineInfo(Stream.of(lineId).collect(Collectors.toList()));
|
||||
LedgerBaseInfoDTO ledgerBaseInfoDTO = list.get(0);
|
||||
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(ledgerBaseInfoDTO.getStationName()).append(ledgerBaseInfoDTO.getLineName())
|
||||
.append("发生暂降事件,事件特征幅值").append(bigDecimal).append("%,持续时间:").append(jsonObject.get("persisttime").toString()).append("S");
|
||||
//TODO 发送短信
|
||||
System.out.println(stringBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pqsDeptslineService.lambdaQuery().eq(PqsDeptsline::getLineIndex,lineId).eq(PqsDeptsline::getSystype,sysTypeZt);
|
||||
public Set<String> getAllParentDeptIds(Set<String> deptIds) {
|
||||
// 首次获取直接父级
|
||||
List<PqsDepts> allDeptList = pqsDeptsService.lambdaQuery().list();
|
||||
// 递归获取所有父级
|
||||
Set<String> result = recursivelyGetParentIds(deptIds,allDeptList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归获取所有父级ID
|
||||
* @param currentParentIds 当前层级的父级ID集合
|
||||
* @return 所有层级的父级ID集合
|
||||
*/
|
||||
private Set<String> recursivelyGetParentIds(Set<String> currentParentIds,List<PqsDepts> allDeptList) {
|
||||
Set<String> result = new HashSet<>(currentParentIds);
|
||||
Set<String> nextLevelParentIds = new HashSet<>();
|
||||
List<PqsDepts> parentDeptList = allDeptList.stream().filter(it->currentParentIds.contains(it.getDeptsIndex())).collect(Collectors.toList());
|
||||
for(PqsDepts pqsDepts: parentDeptList){
|
||||
if(!pqsDepts.getParentnodeid().equals("0")){
|
||||
nextLevelParentIds.add(pqsDepts.getParentnodeid());
|
||||
}
|
||||
}
|
||||
// 如果有更高层级的父级,继续递归
|
||||
if (!nextLevelParentIds.isEmpty()) {
|
||||
Set<String> deeperParentIds = recursivelyGetParentIds(nextLevelParentIds,allDeptList);
|
||||
result.addAll(deeperParentIds);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.njcn.gather.event.transientes.pojo.param;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* <监测点波形入参>
|
||||
*
|
||||
* @author wr
|
||||
* @createTime: 2023-03-23
|
||||
*/
|
||||
@Data
|
||||
public class MonitorTerminalParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "id")
|
||||
@NotBlank(message = "id不能为空")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "区分主配网(0:主网 1:配网)")
|
||||
@NotNull(message = "区分类别不能为空")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "区分系统(0:pq 1:pms)")
|
||||
@NotNull(message = "区分系统不能为空")
|
||||
private Integer systemType;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.gather.event.transientes.service;
|
||||
|
||||
import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
||||
import com.njcn.gather.event.transientes.pojo.param.MonitorTerminalParam;
|
||||
|
||||
public interface EventGateService {
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述: 暂态事件波形分析
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
WaveDataDTO getTransientAnalyseWave(MonitorTerminalParam param);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
//package com.njcn.gather.event.transientes.service.impl;
|
||||
//
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.common.pojo.exception.BusinessException;
|
||||
//import com.njcn.common.utils.PubUtils;
|
||||
//import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
||||
//import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
|
||||
//import com.njcn.gather.event.transientes.pojo.param.MonitorTerminalParam;
|
||||
//import com.njcn.gather.event.transientes.pojo.po.PqsEventdetail;
|
||||
//import com.njcn.gather.event.transientes.service.EventGateService;
|
||||
//import com.njcn.gather.event.transientes.service.PqsEventdetailService;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.InputStream;
|
||||
//import java.util.Objects;
|
||||
//
|
||||
///**
|
||||
// * @Author: cdf
|
||||
// * @CreateTime: 2025-06-30
|
||||
// * @Description:
|
||||
// */
|
||||
//@Service
|
||||
//@RequiredArgsConstructor
|
||||
//@Slf4j
|
||||
//public class EventGateServiceImpl implements EventGateService {
|
||||
//
|
||||
// private final PqsEventdetailService pqsEventdetailService;
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public WaveDataDTO getTransientAnalyseWave(MonitorTerminalParam param) {
|
||||
// WaveDataDTO waveDataDTO;
|
||||
// //获取暂降事件
|
||||
// PqsEventdetail eventDetail = pqsEventdetailService.getById(param.getId());
|
||||
// LineDetailDataVO lineDetailData = new LineDetailDataVO();
|
||||
// MonitorVO monitorVO = new MonitorVO();
|
||||
// String ip;
|
||||
// if (param.getSystemType() == 0) {
|
||||
// lineDetailData = lineFeignClient.getLineDetailData(eventDetail.getMeasurementPointId()).getData();
|
||||
// ip = lineDetailData.getIp();
|
||||
// } else {
|
||||
// param.setId(eventDetail.getMeasurementPointId());
|
||||
// monitorVO = monitorClient.getMonitorTerminal(param).getData();
|
||||
// ip = monitorVO.getIp();
|
||||
// }
|
||||
// String waveName = eventDetail.getWavePath();
|
||||
// String cfgPath, datPath, cfgPath2, datPath2;
|
||||
// if (generalInfo.getBusinessWaveFileStorage() == GeneralConstant.LOCAL_DISK) {
|
||||
// cfgPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG;
|
||||
// datPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT;
|
||||
// log.info("本地磁盘波形文件路径----" + cfgPath);
|
||||
// InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath);
|
||||
// InputStream datStream = waveFileComponent.getFileInputStreamByFilePath(datPath);
|
||||
// if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||
// throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
// }
|
||||
// waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
|
||||
// } else {
|
||||
// cfgPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG;
|
||||
// datPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT;
|
||||
// //适配文件后缀小写
|
||||
// cfgPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG.toLowerCase();
|
||||
// datPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT.toLowerCase();
|
||||
// log.info("文件服务器波形文件路径----" + cfgPath);
|
||||
// try (
|
||||
// InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath);
|
||||
// InputStream datStream = fileStorageUtil.getFileStream(datPath)
|
||||
// ) {
|
||||
// if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||
// throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
// }
|
||||
// waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
|
||||
// } catch (Exception e) {
|
||||
// try {
|
||||
// InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath2);
|
||||
// InputStream datStream = fileStorageUtil.getFileStream(datPath2);
|
||||
// if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||
// throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
// }
|
||||
// waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
|
||||
// } catch (Exception e1) {
|
||||
// throw new BusinessException(WaveFileResponseEnum.WAVE_DATA_INVALID);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// waveDataDTO = waveFileComponent.getValidData(waveDataDTO);
|
||||
// if (param.getSystemType() == 0) {
|
||||
// waveDataDTO.setPtType(PubUtils.ptTypeName(lineDetailData.getPtType()));
|
||||
// double pt1 = Double.parseDouble(lineDetailData.getPt().split(StrUtil.SLASH)[0]);
|
||||
// double pt2 = Double.parseDouble(lineDetailData.getPt().split(StrUtil.SLASH)[1]);
|
||||
// double ct1 = Double.parseDouble(lineDetailData.getCt().split(StrUtil.SLASH)[0]);
|
||||
// double ct2 = Double.parseDouble(lineDetailData.getCt().split(StrUtil.SLASH)[1]);
|
||||
// waveDataDTO.setPt(pt1 / pt2);
|
||||
// waveDataDTO.setCt(ct1 / ct2);
|
||||
// return waveDataDTO;
|
||||
// }
|
||||
// waveDataDTO.setPtType(Integer.valueOf(monitorVO.getTerminalWiringMethod()));
|
||||
// waveDataDTO.setPt(monitorVO.getPt1() / monitorVO.getPt2());
|
||||
// waveDataDTO.setCt(monitorVO.getCt1() / monitorVO.getCt2());
|
||||
// return waveDataDTO;
|
||||
// }
|
||||
//}
|
||||
@@ -443,9 +443,23 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
@Override
|
||||
public List<EventDetailVO> noDealEventList(LargeScreenCountParam largeScreenCountParam) {
|
||||
List<EventDetailVO> result = new ArrayList<>();
|
||||
|
||||
DateTime end = DateUtil.endOfDay(DateTime.now());
|
||||
DateTime start = DateUtil.beginOfMonth(DateTime.now());
|
||||
//起始时间
|
||||
LocalDateTime startTime;
|
||||
//结束时间
|
||||
LocalDateTime endTime;
|
||||
if (largeScreenCountParam.getType() == 3) {
|
||||
//起始时间
|
||||
startTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.beginOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
//结束时间
|
||||
endTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.endOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
} else if (largeScreenCountParam.getType() == 4) {
|
||||
//起始时间
|
||||
startTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.beginOfWeek(new Date()), DatePattern.NORM_DATETIME_FORMATTER), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
//结束时间
|
||||
endTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.endOfWeek(new Date()), DatePattern.NORM_DATETIME_FORMATTER), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
} else {
|
||||
throw new BusinessException("统计类型有误类型");
|
||||
}
|
||||
//根据用户获取当前部门及子部门id
|
||||
List<String> deptAndChildren = pqsDeptsService.findDeptAndChildren(largeScreenCountParam.getDeptId());
|
||||
//获取对应监测点id
|
||||
@@ -455,7 +469,7 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
return result;
|
||||
}
|
||||
LambdaQueryWrapper<PqsEventdetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.between(PqsEventdetail::getTimeid, start, end)
|
||||
lambdaQueryWrapper.between(PqsEventdetail::getTimeid, startTime, endTime)
|
||||
.in(PqsEventdetail::getLineid, deptslineIds)
|
||||
.and(wrapper -> wrapper.eq(PqsEventdetail::getLookFlag, 0).or().isNull(PqsEventdetail::getLookFlag));
|
||||
if (Objects.nonNull(largeScreenCountParam.getEventDeep())) {
|
||||
@@ -561,7 +575,6 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
@Override
|
||||
public EventMsgDetailVO eventMsgDetail(String eventId) {
|
||||
EventMsgDetailVO eventMsgDetailVO = new EventMsgDetailVO();
|
||||
|
||||
LambdaQueryWrapper<MessageEventFeedback> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(MessageEventFeedback::getEventIndex, eventId);
|
||||
MessageEventFeedback messageEventFeedback = messageEventFeedbackService.getOne(lambdaQueryWrapper);
|
||||
@@ -573,7 +586,6 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
eventMsgDetailVO.setObjName(pqLinedetail.getObjname());
|
||||
}
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<MsgEventInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MsgEventInfo::getEventIndex, eventId);
|
||||
List<MsgEventInfo> msgEventInfoList = msgEventInfoService.list(queryWrapper);
|
||||
|
||||
@@ -103,7 +103,6 @@ public class WebSocketServer {
|
||||
private final Object lock = new Object();
|
||||
|
||||
public void sendMessageToAll(String message) {
|
||||
|
||||
sessions.forEach((userId, session) -> {
|
||||
System.out.println("给用户推送消息" + userId);
|
||||
if (session.isOpen()) {
|
||||
|
||||
Reference in New Issue
Block a user