1.监测点运行状态数据调整;

2.暂态事件同步
This commit is contained in:
xy
2026-01-16 14:57:44 +08:00
parent 0ac51648f4
commit 4497699178
10 changed files with 311 additions and 41 deletions

View File

@@ -1,7 +1,5 @@
package com.njcn.csdevice.controller.line;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
@@ -28,10 +26,8 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Description:
@@ -284,16 +280,7 @@ public class CslineController extends BaseController {
@ApiImplicitParam(name = "param", value = "param", required = true)
public HttpResult<List<CsLinePO>> list(@RequestBody CsLinePO param) {
String methodDescribe = getMethodDescribe("list");
List<String> keywordsLineIds = new ArrayList<>();
List<CsLinePO> poList = csLinePOService.getSimpleLine();
if (CollUtil.isNotEmpty(poList)) {
keywordsLineIds = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
}
List<CsLinePO> list = csLinePOService.list(new LambdaQueryWrapper<CsLinePO>()
.eq(CsLinePO::getStatus, 1)
.eq(StrUtil.isNotBlank(param.getPosition()), CsLinePO::getPosition, param.getPosition())
.in(CsLinePO::getLineId, keywordsLineIds)
.orderByAsc(CsLinePO::getName));
List<CsLinePO> list = csLinePOService.getLineList(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}

View File

@@ -95,4 +95,6 @@ public interface CsLinePOService extends IService<CsLinePO>{
* @return 结果
*/
LineDetailDataVO getLineDetailData(String id);
List<CsLinePO> getLineList(CsLinePO param);
}

View File

@@ -942,9 +942,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
devList.forEach(item->{item.setRunStatus(1);});
this.updateBatchById(devList);
//修改监测点运行状态
List<String> devIdList = devList.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
List<CsLinePO> lineList = csLinePOService.getLinesByDevList(devIdList);
csLinePOService.updateCldLineStatus(lineList,2);
//List<String> devIdList = devList.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
//List<CsLinePO> lineList = csLinePOService.getLinesByDevList(devIdList);
//csLinePOService.updateCldLineStatus(lineList,2);
}
}
@@ -958,9 +958,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
if (ObjectUtil.isNotNull(po)) {
po.setRunStatus(status);
this.updateById(po);
//这边是监测点的运行状态 不是通讯状态,所以不要修改,通讯状态跟着设备的通讯状态来
//修改监测点运行状态
List<CsLinePO> lineList = csLinePOService.getLinesByDevList(Collections.singletonList(po.getId()));
csLinePOService.updateCldLineStatus(lineList,status==1?2:0);
//List<CsLinePO> lineList = csLinePOService.getLinesByDevList(Collections.singletonList(po.getId()));
//csLinePOService.updateCldLineStatus(lineList,status==1?2:0);
}
}

View File

@@ -369,19 +369,21 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
}
// 运行状态
if (ObjectUtil.isNotNull(record.getRunStatus())) {
sensitiveUserLineVO.setRunStatus(getRunStatusDescription(record.getRunStatus()));
//获取设备状态
int devRunStatus = csEquipmentDeliveryMapper.selectById(record.getDeviceId()).getRunStatus();
sensitiveUserLineVO.setRunStatus(getRunStatusDescription(devRunStatus));
}
// 报告文件
sensitiveUserLineVO.setReportFilePath(record.getReportFilePath());
// 最新数据时间
List<CsLineLatestData> lineLatestDataList = csLineLatestDataFeignClient.listData().getData();
if (CollUtil.isNotEmpty(lineLatestDataList)) {
sensitiveUserLineVO.setLatestTime(lineLatestDataList.stream()
.filter(item -> item.getLineId().equals(record.getLineId()))
.map(CsLineLatestData::getTimeId)
.max(LocalDateTime::compareTo)
.orElse(null));
}
// List<CsLineLatestData> lineLatestDataList = csLineLatestDataFeignClient.listData().getData();
// if (CollUtil.isNotEmpty(lineLatestDataList)) {
// sensitiveUserLineVO.setLatestTime(lineLatestDataList.stream()
// .filter(item -> item.getLineId().equals(record.getLineId()))
// .map(CsLineLatestData::getTimeId)
// .max(LocalDateTime::compareTo)
// .orElse(null));
// }
list.add(sensitiveUserLineVO);
}
result.setRecords(list);
@@ -443,23 +445,41 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
return lineDetailDataVO;
}
}
@Override
public List<CsLinePO> getLineList(CsLinePO param) {
List<CsLinePO> result = new ArrayList<>();
List<String> keywordsLineIds = new ArrayList<>();
List<CsLinePO> poList = getSimpleLine();
if (CollUtil.isNotEmpty(poList)) {
keywordsLineIds = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
}
List<CsLinePO> list = this.list(new LambdaQueryWrapper<CsLinePO>()
.eq(CsLinePO::getStatus, 1)
.eq(StrUtil.isNotBlank(param.getPosition()), CsLinePO::getPosition, param.getPosition())
.in(CsLinePO::getLineId, keywordsLineIds)
.orderByAsc(CsLinePO::getName));
//根据监测点id查询设备信息
if (CollectionUtil.isNotEmpty(list)) {
//获取设备信息集合
List<String> devList = list.stream().map(CsLinePO::getDevId).collect(Collectors.toList());
List<CsEquipmentDeliveryPO> equipmentDeliveryList = csEquipmentDeliveryMapper.selectBatchIds(devList);
Map<String,Integer> runStatusMap = equipmentDeliveryList.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId,CsEquipmentDeliveryPO::getRunStatus));
list.forEach(item->{
item.setRunStatus(runStatusMap.get(item.getDevId()));
});
}
return result;
}
private String getRunStatusDescription(Integer runStatus) {
// 0运行1检修2停运3调试4退运
switch (runStatus) {
case 0:
return "运行";
case 1:
return "检修";
return "离线";
case 2:
return "停运";
case 3:
return "调试";
case 4:
return "退运";
return "在线";
default:
return "未知";
}

View File

@@ -0,0 +1,127 @@
package com.njcn.csharmonic.pojo.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 暂降明细实体类
*
* @author yzh
* @since 2022-10-12 18:34:55
*/
@Data
@TableName("r_mp_event_detail")
@ApiModel(value="RmpEventDetail对象")
public class RmpEventDetailPO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "暂时事件ID")
@TableId(value = "event_id", type = IdType.ASSIGN_ID)
private String eventId;
@ApiModelProperty(value = "监测点ID")
private String measurementPointId;
@ApiModelProperty(value = "监测点ID(复制)")
@TableField("measurement_point_id")
private String lineId;
@ApiModelProperty(value = "统计类型")
private String eventType;
@ApiModelProperty(value = "暂降原因Event_Reason")
@TableField("advance_reason")
private String advanceReason;
@ApiModelProperty(value = "暂降类型Event_Type")
@TableField("advance_type")
private String advanceType;
@ApiModelProperty(value = "事件关联分析表Guid")
private String eventassIndex;
@ApiModelProperty(value = "dq计算持续时间 ")
private Double dqTime;
@ApiModelProperty(value = "特征值计算更新时间外键PQS_Relevance的Time字段")
private LocalDateTime dealTime;
@ApiModelProperty(value = "默认事件个数为0")
private Integer num;
@ApiModelProperty(value = "波形文件是否从装置招到本地(0未招1已招)默认值为0")
private Integer fileFlag;
@ApiModelProperty(value = "特征值计算标志0未处理1已处理; 2已处理无结果;3计算失败默认值为0")
private Integer dealFlag;
@ApiModelProperty(value = "处理结果第一条事件发生时间(读comtra文件获取)")
private LocalDateTime firstTime;
@ApiModelProperty(value = "处理结果第一条事件暂降类型字典表PQS_Dicdata")
private String firstType;
@ApiModelProperty(value = "处理结果第一条事件发生时间毫秒(读comtra文件获取)")
private Double firstMs;
@ApiModelProperty(value = "暂降能量")
private Double energy;
@ApiModelProperty(value = "暂降严重度")
private Double severity;
@ApiModelProperty(value = "暂降源与监测位置关系 Upper:上游Lower :下游Unknown :未知;为空则是未计算")
private String sagsource;
@ApiModelProperty(value = "开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private LocalDateTime startTime;
@ApiModelProperty(value = "格式化开始时间")
@TableField(exist = false)
private String formatTime;
@ApiModelProperty(value = "持续时间,单位秒")
private Double duration;
@ApiModelProperty(value = "特征幅值")
private Double featureAmplitude;
@ApiModelProperty(value = "相别")
private String phase;
@ApiModelProperty(value = "事件描述")
private String eventDescribe;
@ApiModelProperty(value = "波形路径")
private String wavePath;
@ApiModelProperty(value = "暂降核实原因")
@TableField("verify_reason")
private String verifyReason;
@ApiModelProperty(value = "暂降核实原因详情")
@TableField("verify_reason_detail")
private String verifyReasonDetail;
private Double transientValue;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@ApiModelProperty(value = "用于计算数量")
@TableField(exist = false)
private Integer count;
}

View File

@@ -0,0 +1,18 @@
package com.njcn.csharmonic.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csharmonic.pojo.po.RmpEventDetailPO;
import org.apache.ibatis.annotations.Mapper;
/**
* 暂态事件明细
*
* @author yzh
* @date 2022/10/12
*/
@Mapper
@DS("sjzx")
public interface RmpEventDetailMapper extends BaseMapper<RmpEventDetailPO> {
}

View File

@@ -21,7 +21,11 @@
SELECT
t1.line_id id,
t2.NAME,
t1.start_time timeId,
CONCAT(
DATE_FORMAT( t1.start_time, '%Y-%m-%d %H:%i:%s' ),
'.',
LPAD( FLOOR( MICROSECOND( t1.start_time ) / 1000 ), 3, '0' )
) AS timeId,
t1.amplitude,
t1.persist_time
FROM
@@ -34,6 +38,7 @@
#{lineId}
</foreach>
and t1.type = 0
order by t1.start_time DESC
LIMIT 60
</select>

View File

@@ -0,0 +1,15 @@
package com.njcn.csharmonic.service.event;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csharmonic.pojo.po.RmpEventDetailPO;
/**
* 暂态事件明细
*
* @author yzh
* @date 2022/10/12
*/
public interface RmpEventDetailService extends IService<RmpEventDetailPO> {
}

View File

@@ -9,6 +9,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ZipUtil;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -22,18 +23,21 @@ import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
import com.njcn.csharmonic.enums.CsEventEnum;
import com.njcn.csharmonic.enums.CsTransientEnum;
import com.njcn.csharmonic.mapper.CsEventPOMapper;
import com.njcn.csharmonic.mapper.RmpEventDetailMapper;
import com.njcn.csharmonic.param.CldEventParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.param.DataParam;
import com.njcn.csharmonic.pojo.param.EventStatisticParam;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.po.RmpEventDetailPO;
import com.njcn.csharmonic.pojo.vo.CsEventVO;
import com.njcn.csharmonic.pojo.vo.CsWarnDescVO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.csharmonic.pojo.vo.EventStatisticsVo;
import com.njcn.csharmonic.service.CsEventPOService;
import com.njcn.csharmonic.service.CsEventUserPOService;
import com.njcn.csharmonic.service.event.RmpEventDetailService;
import com.njcn.event.file.component.WaveFileComponent;
import com.njcn.event.file.component.WavePicComponent;
import com.njcn.event.file.pojo.bo.WaveDataDetail;
@@ -48,8 +52,11 @@ import com.njcn.minioss.config.MinIossProperties;
import com.njcn.minioss.util.MinIoUtils;
import com.njcn.oss.constant.GeneralConstant;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.EleEvtFeignClient;
import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.system.pojo.po.EleEvtParm;
import com.njcn.web.factory.PageFactory;
@@ -107,6 +114,9 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
private final MinIossProperties minIossProperties;
private final InfluxDbUtils influxDbUtils;
private final MinIoUtils minIoUtils;
private final DicDataFeignClient dicDataFeignClient;
private final RmpEventDetailService rmpEventDetailService;
private final RmpEventDetailMapper rmpEventDetailMapper;
@Override
public List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam) {
@@ -328,7 +338,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
}
@Override
@Transactional(rollbackFor = Exception.class)
@DSTransactional
public void addCldEvent(CldEventParam param) {
//校验是新增时间还是更新文件信息
LambdaQueryWrapper<CsEventPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -368,6 +378,10 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
if (CollectionUtil.isNotEmpty(records)) {
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, records);
}
//同步数据到 r_mp_event_detail
insertEvent(uuid, param, time);
} else {
if (StrUtil.isNotBlank(param.getWavePath())) {
//更新文件信息
@@ -377,10 +391,35 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
.eq(CsEventPO::getStartTime,param.getStartTime())
.set(CsEventPO::getWavePath,param.getWavePath())
.update();
//更新文件信息
updateEvent(param);
}
}
}
public void insertEvent(String uuid, CldEventParam param, LocalDateTime time) {
RmpEventDetailPO rmpEventDetailPO = new RmpEventDetailPO();
rmpEventDetailPO.setEventId(uuid);
rmpEventDetailPO.setMeasurementPointId(param.getMonitorId());
rmpEventDetailPO.setStartTime(time);
rmpEventDetailPO.setEventType(getEventType(param.getEventType()));
rmpEventDetailPO.setFeatureAmplitude(param.getAmplitude() * 100);
rmpEventDetailPO.setDuration(param.getDuration());
rmpEventDetailPO.setEventDescribe(getTag(param.getEventType()));
rmpEventDetailPO.setPhase(param.getPhase());
rmpEventDetailService.save(rmpEventDetailPO);
}
public void updateEvent(CldEventParam param) {
LambdaQueryWrapper<RmpEventDetailPO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RmpEventDetailPO::getMeasurementPointId,param.getMonitorId()).eq(RmpEventDetailPO::getStartTime,param.getStartTime());
RmpEventDetailPO po = rmpEventDetailMapper.selectOne(wrapper);
po.setWavePath(param.getWavePath());
rmpEventDetailService.updateById(po);
}
@Override
public List<CsEventPO> getEventByTime(List<String> lineList, String startTime, String endTime) {
LambdaQueryWrapper<CsEventPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -414,7 +453,15 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
csWarnDescVOList = this.baseMapper.getEventDesc(lineIdList,60);
// 处理下描述
for (CsWarnDescVO csWarnDescVO : csWarnDescVOList) {
csWarnDescVO.setEventDesc("电压暂态事件,持续时间"+csWarnDescVO.getPersistTime()+"秒,电压降至"+csWarnDescVO.getAmplitude()+"%。");
String desc;
if(csWarnDescVO.getAmplitude() <= 90) {
desc = "降至";
} else if (csWarnDescVO.getAmplitude() >= 110) {
desc = "升至";
} else {
desc = "维持";
}
csWarnDescVO.setEventDesc("电压暂态事件,持续时间"+csWarnDescVO.getPersistTime()+"秒,电压"+desc+csWarnDescVO.getAmplitude()+"%。");
}
return csWarnDescVOList;
}
@@ -441,7 +488,27 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
return tag;
}
public String getEventType(Integer type) {
String tag;
switch (type) {
case 1:
DictData dip = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
tag = dip.getId();
break;
case 2:
DictData rise = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_RISE.getCode()).getData();
tag = rise.getId();
break;
case 3:
DictData interruptions = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();
tag = interruptions.getId();
break;
default:
tag = "Un_Know";
break;
}
return tag;
}
/**

View File

@@ -0,0 +1,28 @@
package com.njcn.csharmonic.service.impl.event;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csharmonic.mapper.RmpEventDetailMapper;
import com.njcn.csharmonic.pojo.po.RmpEventDetailPO;
import com.njcn.csharmonic.service.event.RmpEventDetailService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* 暂态事件明细
*
* @author yzh
* @date 2022/10/12
*/
@Service
@Slf4j
@RequiredArgsConstructor
@DS("sjzx")
public class RmpEventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, RmpEventDetailPO> implements RmpEventDetailService {
}