feat(harmonic): 优化事件管理功能并调整日志级别
- 将多个模块的根日志级别从info调整为warn - 在CldEventParam中为幅值和持续时间字段添加更明确的描述 - 为CommonStatisticalQueryParam添加持续时间、特征幅值、严重度等范围验证参数 - 在CsEngineeringServiceImpl中添加排序功能支持 - 为设备交付相关参数和实体类添加治理方法、敏感用户、治理类型等新字段 - 在事件服务中实现持续时间、幅值、严重度等多维度筛选查询功能 - 为CsEventPO添加严重度字段并实现相关计算逻辑 - 优化事件列表查询性能,添加波形文件存在性过滤条件 - 更新XML映射文件以支持新的查询参数和字段映射 - 重构台账树构建逻辑,提升数据加载效率 - 修复数据查询中的大小写匹配问题
This commit is contained in:
@@ -1,39 +1,25 @@
|
||||
package com.njcn.csdevice.controller.ledger;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
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.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.mapper.PqsDeviceUnitMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.service.CsCommTerminalService;
|
||||
import com.njcn.csdevice.service.CsDeviceUserPOService;
|
||||
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.constant.UserType;
|
||||
import com.njcn.user.pojo.vo.UserVO;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
<select id="getRecordAll" resultType="com.njcn.csdevice.pojo.vo.RecordAllDevTreeVo">
|
||||
<if test="wlRecordPageParam.isTrueFlag == 0">
|
||||
select a.dev_id as id,b.name as name from wl_record a
|
||||
select a.dev_id as id,b.name as name,b.run_status as runStatus from wl_record a
|
||||
left join cs_equipment_delivery b on a.dev_id = b.id
|
||||
where a.type=1 and a.state =1 and a.end_time is not null
|
||||
and
|
||||
@@ -31,7 +31,7 @@
|
||||
group by a.dev_id,b.name having a.dev_id is not null and b.name is not null
|
||||
</if>
|
||||
<if test="wlRecordPageParam.isTrueFlag == 1">
|
||||
select a.dev_id as id,b.name as name from wl_record a
|
||||
select a.dev_id as id,b.name as name,b.run_status as runStatus from wl_record a
|
||||
left join cs_equipment_delivery b on a.dev_id = b.id
|
||||
where a.type=1 and a.state =1 and a.end_time is not null
|
||||
and exists
|
||||
|
||||
@@ -138,6 +138,7 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
|
||||
if(StringUtils.isNotBlank(csEngineeringAuditParm.getName())){
|
||||
csLedger1.setName(csEngineeringAuditParm.getName());
|
||||
}
|
||||
csLedger1.setSort(csEngineeringAuditParm.getSort());
|
||||
csLedgerMapper.updateById(csLedger1);
|
||||
List<CsEngineeringPO> list = this.lambdaQuery().eq(CsEngineeringPO::getName, csEngineeringAuditParm.getName()).eq(CsEngineeringPO::getStatus, "1").list();
|
||||
if(list.size()>1){
|
||||
|
||||
@@ -25,12 +25,14 @@ import com.njcn.csdevice.mapper.CsDataSetMapper;
|
||||
import com.njcn.csdevice.mapper.CsGroArrMapper;
|
||||
import com.njcn.csdevice.mapper.CsGroupMapper;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.dto.CsLineDTO;
|
||||
import com.njcn.csdevice.pojo.param.EnergyBaseParam;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
||||
import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
|
||||
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
|
||||
import com.njcn.csdevice.pojo.vo.EnergyTemplateVO;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.csdevice.service.ICsDataArrayService;
|
||||
import com.njcn.csdevice.service.ICsGroupService;
|
||||
import com.njcn.csdevice.service.ICsLedgerService;
|
||||
@@ -109,6 +111,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
|
||||
private final String GRID_SIDE_DICT_CODE = "Grid_Side";
|
||||
private final String LOAD_SIDE_DICT_CODE = "Load_Side";
|
||||
private final CsLinePOService csLinePOService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -517,9 +520,24 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
csEventUserQueryPage.setLineId(commonStatisticalQueryParam.getLineId());
|
||||
csEventUserQueryPage.setStartTime(commonStatisticalQueryParam.getStartTime());
|
||||
csEventUserQueryPage.setEndTime(commonStatisticalQueryParam.getEndTime());
|
||||
csEventUserQueryPage.setEvtParamTmMin(commonStatisticalQueryParam.getEvtParamTmMin());
|
||||
csEventUserQueryPage.setEvtParamTmMax(commonStatisticalQueryParam.getEvtParamTmMax());
|
||||
csEventUserQueryPage.setFeatureAmplitudeMin(commonStatisticalQueryParam.getFeatureAmplitudeMin());
|
||||
csEventUserQueryPage.setFeatureAmplitudeMax(commonStatisticalQueryParam.getFeatureAmplitudeMax());
|
||||
csEventUserQueryPage.setSeverityMin(commonStatisticalQueryParam.getSeverityMin());
|
||||
csEventUserQueryPage.setSeverityMax(commonStatisticalQueryParam.getSeverityMax());
|
||||
csEventUserQueryPage.setTarget(commonStatisticalQueryParam.getTarget());
|
||||
csEventUserQueryPage.setFileFlag(commonStatisticalQueryParam.getFileFlag());
|
||||
Page<DataGroupEventVO> csEventVOPage = eventFeignClient.pageQueryByLineId(csEventUserQueryPage).getData();
|
||||
|
||||
//获取监测点电压等级
|
||||
List<CsLineDTO> list = csLinePOService.getAllLineDetail();
|
||||
Map<String, CsLineDTO> map = list.stream().collect(Collectors.toMap(CsLineDTO::getLineId, temp -> temp));
|
||||
csEventVOPage.getRecords().forEach(temp->{
|
||||
//监测点电压等级
|
||||
Double volGrade = map.get(temp.getLineId()).getVolGrade();
|
||||
if (!Objects.isNull(volGrade)) {
|
||||
temp.setLineVoltage(volGrade);
|
||||
}
|
||||
//事件描述、相别、暂降幅值,需要特殊处理赋值
|
||||
//事件描述
|
||||
CsLedger dataById = iCsLedgerService.findDataById(temp.getLineId());
|
||||
@@ -1137,7 +1155,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||
commonQueryParam.setLineId(finalCsLinePO.getLineId());
|
||||
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
|
||||
commonQueryParam.setColumnName(epdPqd.getName() + (StringUtils.isEmpty(param.getFrequency()) ? "" : "_" + param.getFrequency()));
|
||||
commonQueryParam.setColumnName(epdPqd.getOtherName() + (StringUtils.isEmpty(param.getFrequency()) ? "" : "_" + param.getFrequency()));
|
||||
commonQueryParam.setPhasic(epdPqd.getPhase());
|
||||
|
||||
commonQueryParam.setStartTime(DateUtil.format(DateUtil.parse(fittingDataQueryParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN), DatePattern.NORM_DATETIME_PATTERN));
|
||||
@@ -1146,7 +1164,9 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
String dataType = param.getValueType();
|
||||
if (StrUtil.isEmpty(dataType)) {
|
||||
// 电能质量指标,取限值计算类型,判断是否越限
|
||||
dataType = epdPqd.getFormula();
|
||||
dataType = epdPqd.getFormula().toUpperCase();
|
||||
} else {
|
||||
dataType = dataType.toUpperCase();
|
||||
}
|
||||
commonQueryParam.setDataType(dataType);
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
import com.njcn.csdevice.api.CsMarketDataFeignClient;
|
||||
import com.njcn.csdevice.constant.DataParam;
|
||||
import com.njcn.csdevice.enums.LineBaseEnum;
|
||||
import com.njcn.csdevice.mapper.*;
|
||||
@@ -1171,60 +1170,33 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
public CsLedgerVO cldTree() {
|
||||
List<CsLedgerVO> allList = this.baseMapper.getAll();
|
||||
if (CollectionUtil.isEmpty(allList)) {
|
||||
CsLedgerVO government = new CsLedgerVO();
|
||||
government.setLevel(-1);
|
||||
government.setName("台账树");
|
||||
government.setPid("0");
|
||||
government.setId(IdUtil.simpleUUID());
|
||||
government.setChildren(new ArrayList<>());
|
||||
return government;
|
||||
return buildTreeRootNode(new ArrayList<>());
|
||||
}
|
||||
|
||||
List<CsLedgerVO> engineeringList = allList.stream()
|
||||
.filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode()))
|
||||
Map<Integer, List<CsLedgerVO>> levelMap = allList.stream()
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.groupingBy(CsLedgerVO::getLevel));
|
||||
|
||||
List<CsLedgerVO> projectList = allList.stream()
|
||||
.filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode()))
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<CsLedgerVO> deviceList = allList.stream()
|
||||
.filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode()))
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<CsLedgerVO> lineList = allList.stream()
|
||||
.filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode()))
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
List<CsLedgerVO> engineeringList = levelMap.getOrDefault(LineBaseEnum.ENGINEERING_LEVEL.getCode(), new ArrayList<>());
|
||||
List<CsLedgerVO> projectList = levelMap.getOrDefault(LineBaseEnum.PROJECT_LEVEL.getCode(), new ArrayList<>());
|
||||
List<CsLedgerVO> deviceList = levelMap.getOrDefault(LineBaseEnum.DEVICE_LEVEL.getCode(), new ArrayList<>());
|
||||
List<CsLedgerVO> lineList = levelMap.getOrDefault(LineBaseEnum.LINE_LEVEL.getCode(), new ArrayList<>());
|
||||
|
||||
if (CollectionUtil.isEmpty(deviceList)) {
|
||||
CsLedgerVO government = new CsLedgerVO();
|
||||
government.setLevel(-1);
|
||||
government.setName("台账树");
|
||||
government.setPid("0");
|
||||
government.setId(IdUtil.simpleUUID());
|
||||
government.setChildren(engineeringList);
|
||||
return government;
|
||||
Map<String, List<CsLedgerVO>> projectByPidMap = projectList.stream()
|
||||
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
|
||||
engineeringList.forEach(eng -> eng.setChildren(projectByPidMap.getOrDefault(eng.getId(), new ArrayList<>())));
|
||||
return buildTreeRootNode(engineeringList);
|
||||
}
|
||||
|
||||
// 批量查询设备交付信息
|
||||
List<String> devIds = deviceList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryPO> devs = csEquipmentDeliveryMapper.selectBatchIds(devIds);
|
||||
Map<String, CsEquipmentDeliveryPO> devsMap = devs.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, Function.identity()));
|
||||
Map<String, String> lineDevMap = lineList.stream().collect(Collectors.toMap(CsLedgerVO::getId, CsLedgerVO::getPid));
|
||||
|
||||
Set<String> cldDevIds = devs.stream()
|
||||
.map(CsEquipmentDeliveryPO::getId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Map<String, List<CsLedgerVO>> projectToDeviceMap = deviceList.stream()
|
||||
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
|
||||
|
||||
Map<String, List<CsLedgerVO>> deviceToLineMap = lineList.stream()
|
||||
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
|
||||
Map<String, CsEquipmentDeliveryPO> devsMap = devs.stream()
|
||||
.collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, Function.identity()));
|
||||
Set<String> cldDevIds = devs.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toSet());
|
||||
|
||||
// 填充设备状态信息
|
||||
deviceList.forEach(device -> {
|
||||
CsEquipmentDeliveryPO dev = devsMap.get(device.getId());
|
||||
if (dev != null) {
|
||||
@@ -1233,6 +1205,9 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
}
|
||||
});
|
||||
|
||||
// 填充监测点状态信息
|
||||
Map<String, String> lineDevMap = lineList.stream()
|
||||
.collect(Collectors.toMap(CsLedgerVO::getId, CsLedgerVO::getPid));
|
||||
lineList.forEach(line -> {
|
||||
String devId = lineDevMap.get(line.getId());
|
||||
if (devId != null) {
|
||||
@@ -1243,39 +1218,48 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
}
|
||||
});
|
||||
|
||||
engineeringList.forEach(engineering -> {
|
||||
List<CsLedgerVO> sortedProjects = projectList.stream()
|
||||
.filter(project -> project.getPid().equals(engineering.getId()))
|
||||
.peek(project -> {
|
||||
List<CsLedgerVO> projectDevices = projectToDeviceMap.getOrDefault(project.getId(), new ArrayList<>());
|
||||
if (CollectionUtil.isNotEmpty(projectDevices)) {
|
||||
List<CsLedgerVO> sortedDevices = projectDevices.stream()
|
||||
.filter(device -> cldDevIds.contains(device.getId()))
|
||||
.peek(device -> {
|
||||
List<CsLedgerVO> sortedLines = deviceToLineMap.getOrDefault(device.getId(), new ArrayList<>())
|
||||
.stream()
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
device.setChildren(sortedLines);
|
||||
})
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
project.setChildren(sortedDevices);
|
||||
}
|
||||
})
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
engineering.setChildren(sortedProjects);
|
||||
// 预构建pid映射
|
||||
Map<String, List<CsLedgerVO>> projectByEngineeringMap = projectList.stream()
|
||||
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
|
||||
Map<String, List<CsLedgerVO>> deviceByProjectMap = deviceList.stream()
|
||||
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
|
||||
Map<String, List<CsLedgerVO>> lineByDeviceMap = lineList.stream()
|
||||
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
|
||||
|
||||
// 逐层构建树:设备 -> 监测点
|
||||
deviceList.forEach(device -> {
|
||||
if (cldDevIds.contains(device.getId())) {
|
||||
device.setChildren(lineByDeviceMap.getOrDefault(device.getId(), new ArrayList<>()));
|
||||
}
|
||||
});
|
||||
|
||||
CsLedgerVO government = new CsLedgerVO();
|
||||
government.setLevel(-1);
|
||||
government.setName("台账树");
|
||||
government.setPid("0");
|
||||
government.setId(IdUtil.simpleUUID());
|
||||
government.setChildren(engineeringList);
|
||||
// 项目 -> 设备(仅包含有交付记录的设备)
|
||||
projectList.forEach(project -> {
|
||||
List<CsLedgerVO> projectDevices = deviceByProjectMap.getOrDefault(project.getId(), new ArrayList<>());
|
||||
if (CollectionUtil.isNotEmpty(projectDevices)) {
|
||||
List<CsLedgerVO> validDevices = projectDevices.stream()
|
||||
.filter(device -> cldDevIds.contains(device.getId()))
|
||||
.collect(Collectors.toList());
|
||||
project.setChildren(validDevices);
|
||||
}
|
||||
});
|
||||
|
||||
return government;
|
||||
// 工程 -> 项目
|
||||
engineeringList.forEach(eng ->
|
||||
eng.setChildren(projectByEngineeringMap.getOrDefault(eng.getId(), new ArrayList<>()))
|
||||
);
|
||||
|
||||
return buildTreeRootNode(engineeringList);
|
||||
}
|
||||
|
||||
private CsLedgerVO buildTreeRootNode(List<CsLedgerVO> children) {
|
||||
CsLedgerVO root = new CsLedgerVO();
|
||||
root.setLevel(-1);
|
||||
root.setName("台账树");
|
||||
root.setPid("0");
|
||||
root.setId(IdUtil.simpleUUID());
|
||||
root.setChildren(children);
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -164,9 +164,8 @@ class IcdServiceImpl implements IcdService {
|
||||
}
|
||||
Integer level = csLedger.getLevel();
|
||||
String[] pids = csLedger.getPids().split(StrUtil.COMMA);
|
||||
Integer sort = csLedger.getSort();
|
||||
// 设置工程信息(所有级别都需要)
|
||||
setEngineeringInfo(vo, level, pids, id, sort);
|
||||
setEngineeringInfo(vo, level, pids, id);
|
||||
// 根据级别设置不同的业务数据
|
||||
switch (level) {
|
||||
case 0:
|
||||
@@ -328,7 +327,7 @@ class IcdServiceImpl implements IcdService {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
event.setMonitorIdList(monitorIds);
|
||||
if (bzType == 0) {
|
||||
if (!Objects.isNull(bzType) && bzType == 0) {
|
||||
event.setDataType(0);
|
||||
} else {
|
||||
event.setDataType(1);
|
||||
@@ -371,7 +370,7 @@ class IcdServiceImpl implements IcdService {
|
||||
reply.setDeviceId(device.getId());
|
||||
reply.setLineId(lineId);
|
||||
reply.setIsReceived(0);
|
||||
if (bzType == 0) {
|
||||
if (!Objects.isNull(bzType) && bzType == 0) {
|
||||
reply.setCode("harmonic");
|
||||
} else {
|
||||
reply.setCode("allEvent");
|
||||
@@ -494,7 +493,7 @@ class IcdServiceImpl implements IcdService {
|
||||
/**
|
||||
* 设置工程信息
|
||||
*/
|
||||
private void setEngineeringInfo(CldLedgerVo vo, Integer level, String[] pids, String id, Integer sort) {
|
||||
private void setEngineeringInfo(CldLedgerVo vo, Integer level, String[] pids, String id) {
|
||||
String engineeringId;
|
||||
|
||||
if (level == 0) {
|
||||
@@ -513,7 +512,7 @@ class IcdServiceImpl implements IcdService {
|
||||
vo.setProvince(po.getProvince());
|
||||
vo.setCity(po.getCity());
|
||||
vo.setEngineeringDescription(po.getDescription());
|
||||
vo.setSort(sort);
|
||||
vo.setSort(po.getSort());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ spring:
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
root: warn
|
||||
|
||||
data:
|
||||
source:
|
||||
|
||||
Reference in New Issue
Block a user