4 Commits

Author SHA1 Message Date
xy
a07a0fe6ed fix(search): 优化事件用户查询功能
- 修改CsEventUserPOMapper.xml中的搜索条件,同时支持名称和代码字段的模糊匹配
- 修复CsEventUserPOServiceImpl中线路ID判断逻辑,避免空字符串和null值导致的异常
- 调整MqttMessageHandler中消息发送的缩进格式,确保代码风格一致
2026-07-14 11:10:46 +08:00
xy
4e7a10f46e feat(device): 更新设备台账和事件查询功能
- 添加AppProjectService依赖以获取项目信息
- 修改项目数量获取逻辑,直接从接口获取项目信息而非设备关联数
- 在事件查询接口中添加线路ID参数支持
- 更新XML映射文件,添加线路ID过滤条件
- 修复便携式设备树结构中的固定ID分配
- 更新便携式工程和项目的固定ID为"1"和"2"
- 优化事件查询服务中的设备和线路ID处理逻辑
2026-07-13 16:35:48 +08:00
xy
b265e95bdf fix(alarm): 修复告警数据显示问题
- 移除多余的代码行和空行
- 添加完整性检测和在线率告警的默认数据构建逻辑
- 实现buildDefaultAlarmData方法为缺失数据提供默认结构
- 确保告警详情显示的完整性和一致性
2026-07-08 10:05:16 +08:00
xy
f185fa4706 feat(event): 添加电能质量事件源信息存储和查询功能
- 在事件详情表中新增 SagSource 字段存储
- 修改 insertEvent 方法增加 sagSource 参数传递
- 优化事件用户查询页面的搜索逻辑,支持按告警码查询
- 更新 XML 映射文件中的搜索条件构建方式
- 添加对电能质量参数 EPD 列表的查询支持
- 修复数据服务中排序字段错误问题
- 补充便携式离线日志处理中的源信息同步
2026-07-07 20:29:05 +08:00
11 changed files with 270 additions and 83 deletions

View File

@@ -60,6 +60,7 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
private final UserFeignClient userFeignClient; private final UserFeignClient userFeignClient;
private final IMqttUserService mqttUserService; private final IMqttUserService mqttUserService;
private final CsCommTerminalFeignClient commTerminalService; private final CsCommTerminalFeignClient commTerminalService;
private final AppProjectService appProjectService;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@@ -272,9 +273,15 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
break; break;
} }
} }
//获取项目数量 //获取项目数量 这边可能项目下没有挂载设备,这边项目数量直接从接口获取
if (CollectionUtil.isNotEmpty(currentProjectIds)) { // if (CollectionUtil.isNotEmpty(currentProjectIds)) {
vo.setCurrentProjectCount(currentProjectIds.size()); // vo.setCurrentProjectCount(currentProjectIds.size());
// }
List<AppProjectPO> projectInfoList = appProjectService.getProjectByEngineering(Collections.singletonList(id));
if (CollectionUtil.isNotEmpty(projectInfoList)) {
vo.setCurrentProjectCount(projectInfoList.size());
} else {
vo.setCurrentProjectCount(0);
} }
//获取设备总数、在线设备、离线设备 //获取设备总数、在线设备、离线设备
if (CollectionUtil.isNotEmpty(currentDevIds)) { if (CollectionUtil.isNotEmpty(currentDevIds)) {

View File

@@ -300,7 +300,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
List<CsLedgerVO> portables = ledger.stream() List<CsLedgerVO> portables = ledger.stream()
.peek(c -> { .peek(c -> {
CsEquipmentDeliveryPO po = poMap2.get(c.getId()); CsEquipmentDeliveryPO po = poMap2.get(c.getId());
c.setPid(portable.getId()); c.setPid("2");
c.setComFlag(po.getRunStatus()); c.setComFlag(po.getRunStatus());
c.setNDId(po.getNdid()); c.setNDId(po.getNdid());
c.setType("device"); c.setType("device");
@@ -365,13 +365,13 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
portable1.setLevel(0); portable1.setLevel(0);
portable1.setName("便携式工程"); portable1.setName("便携式工程");
portable1.setPid("0"); portable1.setPid("0");
portable1.setId(id); portable1.setId("1");
CsLedgerVO portable2 = new CsLedgerVO(); CsLedgerVO portable2 = new CsLedgerVO();
portable2.setLevel(1); portable2.setLevel(1);
portable2.setName("便携式项目"); portable2.setName("便携式项目");
portable2.setPid(id); portable2.setPid("1");
portable2.setId(IdUtil.simpleUUID()); portable2.setId("2");
portable2.setChildren(portables); portable2.setChildren(portables);
portable1.setChildren(Collections.singletonList(portable2)); portable1.setChildren(Collections.singletonList(portable2));
@@ -719,7 +719,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
List<CsLedgerVO> portables = ledger.stream() List<CsLedgerVO> portables = ledger.stream()
.peek(c -> { .peek(c -> {
CsEquipmentDeliveryPO po = poMap2.get(c.getId()); CsEquipmentDeliveryPO po = poMap2.get(c.getId());
c.setPid(portable.getId()); c.setPid("2");
c.setComFlag(po.getRunStatus()); c.setComFlag(po.getRunStatus());
c.setNDId(po.getNdid()); c.setNDId(po.getNdid());
c.setType("device"); c.setType("device");
@@ -776,18 +776,17 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
tree.addAll(new ArrayList<>(engineeringMap.values())); tree.addAll(new ArrayList<>(engineeringMap.values()));
if (CollUtil.isNotEmpty(portables)) { if (CollUtil.isNotEmpty(portables)) {
String id = IdUtil.simpleUUID();
CsLedgerVO portable1 = new CsLedgerVO(); CsLedgerVO portable1 = new CsLedgerVO();
portable1.setLevel(0); portable1.setLevel(0);
portable1.setName("便携式工程"); portable1.setName("便携式工程");
portable1.setPid("0"); portable1.setPid("0");
portable1.setId(id); portable1.setId("1");
CsLedgerVO portable2 = new CsLedgerVO(); CsLedgerVO portable2 = new CsLedgerVO();
portable2.setLevel(1); portable2.setLevel(1);
portable2.setName("便携式项目"); portable2.setName("便携式项目");
portable2.setPid(id); portable2.setPid("1");
portable2.setId(IdUtil.simpleUUID()); portable2.setId("2");
portable2.setChildren(portables); portable2.setChildren(portables);
List<CsLedgerVO> portable2List = new ArrayList<>(); List<CsLedgerVO> portable2List = new ArrayList<>();

View File

@@ -628,6 +628,9 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
} else { } else {
rmpEventDetailPo.setDealFlag(0); rmpEventDetailPo.setDealFlag(0);
} }
if (!Objects.isNull(item.getSagSource())) {
rmpEventDetailPo.setSagsource(item.getSagSource());
}
wlRmpEventDetailMapper.insert(rmpEventDetailPo); wlRmpEventDetailMapper.insert(rmpEventDetailPo);
} }

View File

@@ -7,6 +7,7 @@ import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List;
/** /**
* *
@@ -81,4 +82,6 @@ public class CsEventUserQueryPage extends CsEventUserQueryParam{
@ApiModelProperty(value = "是否是dvr治理效果 0:否 1:是") @ApiModelProperty(value = "是否是dvr治理效果 0:否 1:是")
private Integer isDvr; private Integer isDvr;
private List<String> epdTagList;
} }

View File

@@ -75,7 +75,7 @@ public class MqttMessageHandler {
public void responseRtData(String topic, @NamedValue("pageId") String pageId, MqttMessage message, @Payload String payload) { public void responseRtData(String topic, @NamedValue("pageId") String pageId, MqttMessage message, @Payload String payload) {
List<CsRtDataVO> list = lineTargetService.getLineData(pageId); List<CsRtDataVO> list = lineTargetService.getLineData(pageId);
Gson gson = new Gson(); Gson gson = new Gson();
publisher.send("/zl/rtData/" + pageId, gson.toJson(list), 1, false); publisher.send("/zl/rtData/" + pageId, gson.toJson(list), 1, false);
} }
@MqttSubscribe(value = "/zl/askTemperData/{devId}", qos = 1) @MqttSubscribe(value = "/zl/askTemperData/{devId}", qos = 1)

View File

@@ -36,7 +36,7 @@ public interface CsEventUserPOMapper extends BaseMapper<CsEventUserPO> {
Page<EventDetailVO> queryEventpage(Page<EventDetailVO> returnpage, @Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage, @Param("devIds") List<String> devIds); Page<EventDetailVO> queryEventpage(Page<EventDetailVO> returnpage, @Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage, @Param("devIds") List<String> devIds);
Page<EventDetailVO> queryEventPageWeb(Page<EventDetailVO> returnpage,@Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage,@Param("devIds") List<String> collect); Page<EventDetailVO> queryEventPageWeb(Page<EventDetailVO> returnpage,@Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage,@Param("devIds") List<String> collect,@Param("lineIds") List<String> collect2);
Page<EventDetailVO> queryEventPageWebDvr(Page<EventDetailVO> returnpage,@Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage,@Param("lineIds") List<String> collect); Page<EventDetailVO> queryEventPageWebDvr(Page<EventDetailVO> returnpage,@Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage,@Param("lineIds") List<String> collect);

View File

@@ -223,13 +223,25 @@
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.severityMax != null and csEventUserQueryPage.severityMax !=''"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.severityMax != null and csEventUserQueryPage.severityMax !=''">
AND b.severity &lt; #{csEventUserQueryPage.severityMax} AND b.severity &lt; #{csEventUserQueryPage.severityMax}
</if> </if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.searchValue != null and csEventUserQueryPage.searchValue !=''"> <if test="csEventUserQueryPage != null and csEventUserQueryPage.searchValue != null and csEventUserQueryPage.searchValue != ''">
<if test="csEventUserQueryPage.type != null and csEventUserQueryPage.type !='' and csEventUserQueryPage.type == 3 "> AND (
AND e.name like concat('%',#{csEventUserQueryPage.searchValue},'%') <!-- 名称匹配根据type区分线路名/设备名) -->
</if> <choose>
<if test="csEventUserQueryPage.type != null and csEventUserQueryPage.type !='' and csEventUserQueryPage.type != 3 "> <when test="csEventUserQueryPage.type != null and csEventUserQueryPage.type == 3">
AND d.name like concat('%',#{csEventUserQueryPage.searchValue},'%') (e.name LIKE CONCAT('%', #{csEventUserQueryPage.searchValue}, '%') OR b.code LIKE CONCAT('%', #{csEventUserQueryPage.searchValue}, '%'))
</when>
<otherwise>
d.name LIKE CONCAT('%', #{csEventUserQueryPage.searchValue}, '%')
</otherwise>
</choose>
<!-- OR tag匹配当epdTagList不为空时加入tag IN条件 -->
<if test="csEventUserQueryPage.epdTagList != null and csEventUserQueryPage.epdTagList.size() > 0">
OR b.tag IN
<foreach collection="csEventUserQueryPage.epdTagList" item="tagItem" open="(" separator="," close=")">
#{tagItem}
</foreach>
</if> </if>
)
</if> </if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.fileFlag != null"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.fileFlag != null">
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.fileFlag == 0 "> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.fileFlag == 0 ">
@@ -255,6 +267,12 @@
<foreach collection="devIds" index="index" item="item" open="(" separator="," close=")"> <foreach collection="devIds" index="index" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
<if test="lineIds != null and lineIds.size() > 0">
AND b.line_id IN
<foreach collection="lineIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != null and csEventUserQueryPage.type !=''"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != null and csEventUserQueryPage.type !=''">
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type == 3 "> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.type == 3 ">
AND b.type in (2,3) and b.level in (1,2,3,6,7) AND b.type in (2,3) and b.level in (1,2,3,6,7)
@@ -320,7 +338,8 @@
</if> </if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.searchValue != null and csEventUserQueryPage.searchValue !=''"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.searchValue != null and csEventUserQueryPage.searchValue !=''">
<if test="csEventUserQueryPage.type != null and csEventUserQueryPage.type !='' and csEventUserQueryPage.type == 3 "> <if test="csEventUserQueryPage.type != null and csEventUserQueryPage.type !='' and csEventUserQueryPage.type == 3 ">
AND e.name like concat('%',#{csEventUserQueryPage.searchValue},'%') -- AND e.name like concat('%',#{csEventUserQueryPage.searchValue},'%')
AND (e.name LIKE CONCAT('%', #{csEventUserQueryPage.searchValue}, '%') OR b.code LIKE CONCAT('%', #{csEventUserQueryPage.searchValue}, '%'))
</if> </if>
<if test="csEventUserQueryPage.type != null and csEventUserQueryPage.type !='' and csEventUserQueryPage.type != 3 "> <if test="csEventUserQueryPage.type != null and csEventUserQueryPage.type !='' and csEventUserQueryPage.type != 3 ">
AND d.name like concat('%',#{csEventUserQueryPage.searchValue},'%') AND d.name like concat('%',#{csEventUserQueryPage.searchValue},'%')

View File

@@ -185,9 +185,7 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> impl
for (int i = 0; i < devIds.length; i++) { for (int i = 0; i < devIds.length; i++) {
for (int i1 = 0; i1 < param.getDevList().size(); i1++) { for (int i1 = 0; i1 < param.getDevList().size(); i1++) {
if (Objects.equals(devIds[i], param.getDevList().get(i1))) { if (Objects.equals(devIds[i], param.getDevList().get(i1))) {
CsLedgerVO csLedgerVO = ledgerMap.get(devIds[i]); CsLedgerVO csLedgerVO = ledgerMap.get(devIds[i]);
AlarmVO.AlarmDetail alarmDetail = new AlarmVO.AlarmDetail(); AlarmVO.AlarmDetail alarmDetail = new AlarmVO.AlarmDetail();
alarmDetail.setEngineeringName(ledgerMap.get(csLedgerVO.getPids().split(",")[1]).getName()); alarmDetail.setEngineeringName(ledgerMap.get(csLedgerVO.getPids().split(",")[1]).getName());
alarmDetail.setProjectName(ledgerMap.get(csLedgerVO.getPids().split(",")[2]).getName()); alarmDetail.setProjectName(ledgerMap.get(csLedgerVO.getPids().split(",")[2]).getName());
@@ -243,6 +241,36 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> impl
} }
} }
} }
//特殊处理,如果完整性和在线率没有告警,需要特殊处理下,模拟数据
if (CollectionUtil.isNotEmpty(result)) {
result.forEach(item->{
if (Objects.isNull(item.getDataDetails())) {
item.setDataDetails(buildDefaultAlarmData(item.getDevName()));
}
});
}
return result; return result;
} }
/**
* 构建默认的告警数据详情
* @param deviceId 设备ID
* @return 默认结构的 CsAlarmData
*/
private CsAlarmData buildDefaultAlarmData(String deviceId) {
CsAlarmData defaultData = new CsAlarmData();
defaultData.setDeviceId(deviceId);
// 构建 onlineRate 默认结构
CsAlarmData.OnlineRateAlarm onlineRate = new CsAlarmData.OnlineRateAlarm();
onlineRate.setValue(0.0);
onlineRate.setThreshold(0.0);
onlineRate.setIsAbnormal(false);
defaultData.setOnlineRate(onlineRate);
// 构建 integrity 默认结构
CsAlarmData.IntegrityAlarm integrity = new CsAlarmData.IntegrityAlarm();
integrity.setThreshold(0.0);
integrity.setMonitorPoints(new ArrayList<>());
defaultData.setIntegrity(integrity);
return defaultData;
}
} }

View File

@@ -479,7 +479,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, records); influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, records);
} }
//同步数据到 r_mp_event_detail //同步数据到 r_mp_event_detail
insertEvent(uuid, param, time, eventPo.getSeverity()); insertEvent(uuid, param, time, eventPo.getSeverity(),eventPo.getSagSource());
//获取台账信息 //获取台账信息
DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(po.getDeviceId()).getData(); DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(po.getDeviceId()).getData();
@@ -577,7 +577,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
return result; return result;
} }
public void insertEvent(String uuid, CldEventParam param, LocalDateTime time, Double severity) { public void insertEvent(String uuid, CldEventParam param, LocalDateTime time, Double severity, String sagSource) {
RmpEventDetailPO rmpEventDetailPO = new RmpEventDetailPO(); RmpEventDetailPO rmpEventDetailPO = new RmpEventDetailPO();
rmpEventDetailPO.setEventId(uuid); rmpEventDetailPO.setEventId(uuid);
rmpEventDetailPO.setMeasurementPointId(param.getMonitorId()); rmpEventDetailPO.setMeasurementPointId(param.getMonitorId());
@@ -590,6 +590,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
rmpEventDetailPO.setDealFlag(0); rmpEventDetailPO.setDealFlag(0);
rmpEventDetailPO.setFileFlag(0); rmpEventDetailPO.setFileFlag(0);
rmpEventDetailPO.setSeverity(severity); rmpEventDetailPO.setSeverity(severity);
rmpEventDetailPO.setSagsource(sagSource);
wlRmpEventDetailMapper.insert(rmpEventDetailPO); wlRmpEventDetailMapper.insert(rmpEventDetailPO);
} }

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.csp.sentinel.util.StringUtil; import com.alibaba.csp.sentinel.util.StringUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -414,11 +415,16 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
cldDevTree = cldDevTree.get(0).getChildren(); cldDevTree = cldDevTree.get(0).getChildren();
} }
if (ObjectUtil.isNull(csEventUserQueryPage.getDeviceId()) || StringUtils.isEmpty(csEventUserQueryPage.getDeviceId())) { if (ObjectUtil.isNull(csEventUserQueryPage.getDeviceId()) || StringUtils.isEmpty(csEventUserQueryPage.getDeviceId())) {
//便携式就1层下边就是设备 //便携式就1层下边就是设备 这边给便携式设备添加了假的工程和项目id是写死的
List<String> portableDevIds = portableDevTree.stream().filter( List<String> portableDevIds = new ArrayList<>();
temp -> StringUtils.isEmpty(csEventUserQueryPage.getDeviceId()) || if (Objects.equals(csEventUserQueryPage.getEngineeringid(),"1")
Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId()) || Objects.equals(csEventUserQueryPage.getProjectId(),"2")
).map(CsLedgerVO::getId).collect(Collectors.toList()); || (!ObjectUtil.isNull(csEventUserQueryPage.getLineId()) && !StringUtils.isEmpty(csEventUserQueryPage.getLineId()))) {
portableDevIds = portableDevTree.stream().map(CsLedgerVO::getId).filter(
id -> StringUtils.isEmpty(csEventUserQueryPage.getDeviceId()) ||
Objects.equals(id, csEventUserQueryPage.getDeviceId())
).collect(Collectors.toList());
}
List<String> governmentDevIds = governmentDevTree.stream().filter(temp->StringUtils.isEmpty(csEventUserQueryPage.getEngineeringid())|| List<String> governmentDevIds = governmentDevTree.stream().filter(temp->StringUtils.isEmpty(csEventUserQueryPage.getEngineeringid())||
Objects.equals(temp.getId(), csEventUserQueryPage.getEngineeringid())) Objects.equals(temp.getId(), csEventUserQueryPage.getEngineeringid()))
.map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter( .map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
@@ -453,6 +459,9 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
if (CollectionUtils.isEmpty(devIds)){ if (CollectionUtils.isEmpty(devIds)){
return returnpage; return returnpage;
} }
if (!ObjectUtil.isNull(csEventUserQueryPage.getLineId()) && !StringUtils.isEmpty(csEventUserQueryPage.getLineId())) {
lineIds.add(csEventUserQueryPage.getLineId());
}
} }
//获取tag //获取tag
if (Objects.equals(csEventUserQueryPage.getType(), "0")) { if (Objects.equals(csEventUserQueryPage.getType(), "0")) {
@@ -461,13 +470,24 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
csEventUserQueryPage.setTarget(tag); csEventUserQueryPage.setTarget(tag);
} }
} }
//获取告警码
String searchValue = csEventUserQueryPage.getSearchValue();
if (StrUtil.isNotBlank(searchValue)) {
List<EleEpdPqd> epdList = epdFeignClient.findListByCode(searchValue).getData();
if (CollUtil.isNotEmpty(epdList)) {
List<String> epdTagList = epdList.stream()
.map(EleEpdPqd::getName)
.collect(Collectors.toList());
csEventUserQueryPage.setEpdTagList(epdTagList);
}
}
//获取监测点电压等级 //获取监测点电压等级
List<CsLineDTO> list = csLineFeignClient.getAllLineDetail().getData(); List<CsLineDTO> list = csLineFeignClient.getAllLineDetail().getData();
Map<String, CsLineDTO> map = list.stream().collect(Collectors.toMap(CsLineDTO::getLineId, temp -> temp)); Map<String, CsLineDTO> map = list.stream().collect(Collectors.toMap(CsLineDTO::getLineId, temp -> temp));
if (!Objects.isNull(csEventUserQueryPage.getIsDvr()) && csEventUserQueryPage.getIsDvr() == 1) { if (!Objects.isNull(csEventUserQueryPage.getIsDvr()) && csEventUserQueryPage.getIsDvr() == 1) {
returnpage = this.getBaseMapper().queryEventPageWebDvr(returnpage,csEventUserQueryPage,lineIds); returnpage = this.getBaseMapper().queryEventPageWebDvr(returnpage,csEventUserQueryPage,lineIds);
} else { } else {
returnpage = this.getBaseMapper().queryEventPageWeb(returnpage,csEventUserQueryPage,devIds); returnpage = this.getBaseMapper().queryEventPageWeb(returnpage,csEventUserQueryPage,devIds,lineIds);
} }
returnpage.getRecords().forEach(temp->{ returnpage.getRecords().forEach(temp->{
CsLineDTO dto = map.get(temp.getLineId()); CsLineDTO dto = map.get(temp.getLineId());
@@ -559,65 +579,172 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
@Override @Override
public Page<FrontWarnVo> getFrontWarnInfo(CldWarnParam baseParam) { public Page<FrontWarnVo> getFrontWarnInfo(CldWarnParam baseParam) {
Page<FrontWarnVo> result = new Page<>(baseParam.getPageNum(), baseParam.getPageSize()); Page<FrontWarnVo> result = new Page<>(baseParam.getPageNum(), baseParam.getPageSize());
Page<CsEventPO> page = new Page<>(baseParam.getPageNum(), baseParam.getPageSize());
List<Node> nodeList = nodeFeignClient.nodeAllList().getData();
Map<String, Node> nodeMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(nodeList)) { // 1. 获取全量节点并构建映射始终保留全量map用于后续VO转换
nodeMap = nodeList.stream().collect(Collectors.toMap(Node::getId, Function.identity())); List<Node> nodeList = nodeFeignClient.nodeAllList().getData();
if (ObjectUtil.isNotNull(baseParam.getSearchValue()) || StringUtil.isNotBlank(baseParam.getSearchValue())) { if (CollectionUtil.isEmpty(nodeList)) {
nodeList = nodeList.stream().filter(item-> item.getName().contains(baseParam.getSearchValue()) || item.getIp().contains(baseParam.getSearchValue())).collect(Collectors.toList()); return result;
}
Map<String, Node> nodeMap = nodeList.stream()
.collect(Collectors.toMap(Node::getId, Function.identity(), (a, b) -> a));
// 2. 提取搜索关键词避免重复调用getter
String searchValue = baseParam.getSearchValue();
boolean hasSearchValue = StrUtil.isNotBlank(searchValue);
// 3. 根据搜索词筛选出"名称/IP匹配"的节点ID仅作为OR条件的一部分
List<String> matchedNodeIds;
if (hasSearchValue) {
matchedNodeIds = nodeList.stream()
.filter(item -> item.getName().contains(searchValue)
|| item.getIp().contains(searchValue))
.map(Node::getId)
.collect(Collectors.toList());
} else {
matchedNodeIds = Collections.emptyList();
}
// 4. 全量节点ID用于限定查询总范围防止code LIKE查到无关设备
List<String> allNodeIds = nodeList.stream()
.map(Node::getId)
.collect(Collectors.toList());
// 5. 构建查询条件
LambdaQueryWrapper<CsEventPO> queryWrapper = new LambdaQueryWrapper<>();
// 搜索条件下 deviceId 与 code 改为 OR 关系
if (hasSearchValue) {
if (CollectionUtil.isNotEmpty(matchedNodeIds)) {
// 有匹配节点:(deviceId IN 匹配节点 OR code LIKE) AND deviceId IN 全部节点
queryWrapper.in(CsEventPO::getDeviceId, allNodeIds)
.and(w -> w
.in(CsEventPO::getDeviceId, matchedNodeIds)
.or()
.like(CsEventPO::getCode, searchValue)
);
} else {
// 无匹配节点:仅靠 code LIKE但仍限定在全部节点范围内
queryWrapper.in(CsEventPO::getDeviceId, allNodeIds)
.and(w -> w.like(CsEventPO::getCode, searchValue));
} }
if (CollectionUtil.isNotEmpty(nodeList)) { } else {
List<String> nodeIds = nodeList.stream().map(Node::getId).collect(Collectors.toList()); // 无搜索词:正常按全部节点查询
LambdaQueryWrapper<CsEventPO> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(CsEventPO::getDeviceId, allNodeIds);
queryWrapper.in(CsEventPO::getDeviceId, nodeIds) }
.between(CsEventPO::getStartTime, // 时间范围 & 类型固定条件
DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime())).toString(), queryWrapper.between(CsEventPO::getStartTime,
DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime())).toString()) DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime())).toString(),
.eq(CsEventPO::getType, 4) DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime())).toString())
.orderByDesc(CsEventPO::getStartTime); .eq(CsEventPO::getType, 4)
if (ObjectUtil.isNotNull(baseParam.getLevel()) && StringUtil.isNotBlank(baseParam.getLevel())) { .orderByDesc(CsEventPO::getStartTime);
List<Integer> levelList = Arrays.stream(baseParam.getLevel().split(",")) // 等级筛选
.map(String::trim) if (StrUtil.isNotBlank(baseParam.getLevel())) {
.filter(s -> !s.isEmpty()) List<Integer> levelList = Arrays.stream(baseParam.getLevel().split(","))
.map(Integer::parseInt) .map(String::trim)
.collect(Collectors.toList()); .filter(s -> !s.isEmpty())
queryWrapper.in(CsEventPO::getLevel, levelList); .map(Integer::parseInt)
} .collect(Collectors.toList());
page = csEventPOMapper.selectPage(page, queryWrapper); if (CollectionUtil.isNotEmpty(levelList)) {
queryWrapper.in(CsEventPO::getLevel, levelList);
} }
} }
// 6. 执行分页查询
Page<CsEventPO> page = csEventPOMapper.selectPage(
new Page<>(baseParam.getPageNum(), baseParam.getPageSize()), queryWrapper);
// 7. 结果转换
List<CsEventPO> records = page.getRecords(); List<CsEventPO> records = page.getRecords();
if (CollUtil.isNotEmpty(records)) { if (CollUtil.isEmpty(records)) {
List<FrontWarnVo> frontWarnVos = new ArrayList<>(); return result;
Map<String, Node> finalNodeMap = nodeMap;
page.getRecords().forEach(item->{
FrontWarnVo vo = new FrontWarnVo();
//这边将前置名称放进lineId字段将前置IP放进wavePath字段进程号使用clDid
Node node = finalNodeMap.get(item.getDeviceId());
item.setLineId(Objects.isNull(node) ? null : node.getName());
item.setWavePath(Objects.isNull(node) ? null : node.getIp());
//事件等级(1:Ⅰ级||ERROR 2:Ⅱ级||WARN 3:Ⅲ级||(DEBUG&&NORMAL))
if (item.getLevel() == 4 || item.getLevel() == 5) {
item.setLevel(3);
} else if (item.getLevel() == 6) {
item.setLevel(2);
} else if (item.getLevel() == 7) {
item.setLevel(1);
}
BeanUtils.copyProperties(item, vo);
frontWarnVos.add(vo);
});
result.setRecords(frontWarnVos);
result.setTotal(page.getTotal());
result.setPages(page.getPages());
result.setCurrent(page.getCurrent());
result.setSize(page.getSize());
} }
List<FrontWarnVo> frontWarnVos = records.stream().map(item -> {
FrontWarnVo vo = new FrontWarnVo();
// 填充节点信息使用全量nodeMap而非过滤后的列表
Node node = nodeMap.get(item.getDeviceId());
item.setLineId(node != null ? node.getName() : null);
item.setWavePath(node != null ? node.getIp() : null);
// 事件等级映射: 4,5→3(DEBUG/NORMAL) | 6→2(WARN) | 7→1(ERROR)
Integer level = item.getLevel();
if (level == 4 || level == 5) {
item.setLevel(3);
} else if (level == 6) {
item.setLevel(2);
} else if (level == 7) {
item.setLevel(1);
}
BeanUtils.copyProperties(item, vo);
return vo;
}).collect(Collectors.toList());
result.setRecords(frontWarnVos);
result.setTotal(page.getTotal());
result.setPages(page.getPages());
result.setCurrent(page.getCurrent());
result.setSize(page.getSize());
return result; return result;
} }
// @Override
// public Page<FrontWarnVo> getFrontWarnInfo(CldWarnParam baseParam) {
// Page<FrontWarnVo> result = new Page<>(baseParam.getPageNum(), baseParam.getPageSize());
// Page<CsEventPO> page = new Page<>(baseParam.getPageNum(), baseParam.getPageSize());
// List<Node> nodeList = nodeFeignClient.nodeAllList().getData();
// Map<String, Node> nodeMap = new HashMap<>();
//
// if (CollectionUtil.isNotEmpty(nodeList)) {
// nodeMap = nodeList.stream().collect(Collectors.toMap(Node::getId, Function.identity()));
// if (ObjectUtil.isNotNull(baseParam.getSearchValue()) || StringUtil.isNotBlank(baseParam.getSearchValue())) {
// nodeList = nodeList.stream().filter(item-> item.getName().contains(baseParam.getSearchValue()) || item.getIp().contains(baseParam.getSearchValue())).collect(Collectors.toList());
// }
// if (CollectionUtil.isNotEmpty(nodeList)) {
// List<String> nodeIds = nodeList.stream().map(Node::getId).collect(Collectors.toList());
// LambdaQueryWrapper<CsEventPO> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.in(CsEventPO::getDeviceId, nodeIds)
// .between(CsEventPO::getStartTime,
// DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime())).toString(),
// DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime())).toString())
// .eq(CsEventPO::getType, 4)
// .like(StrUtil.isNotBlank(baseParam.getSearchValue()), CsEventPO::getCode, baseParam.getSearchValue())
// .orderByDesc(CsEventPO::getStartTime);
// if (ObjectUtil.isNotNull(baseParam.getLevel()) && StringUtil.isNotBlank(baseParam.getLevel())) {
// List<Integer> levelList = Arrays.stream(baseParam.getLevel().split(","))
// .map(String::trim)
// .filter(s -> !s.isEmpty())
// .map(Integer::parseInt)
// .collect(Collectors.toList());
// queryWrapper.in(CsEventPO::getLevel, levelList);
// }
// page = csEventPOMapper.selectPage(page, queryWrapper);
// }
// }
// List<CsEventPO> records = page.getRecords();
// if (CollUtil.isNotEmpty(records)) {
// List<FrontWarnVo> frontWarnVos = new ArrayList<>();
// Map<String, Node> finalNodeMap = nodeMap;
// page.getRecords().forEach(item->{
// FrontWarnVo vo = new FrontWarnVo();
// //这边将前置名称放进lineId字段将前置IP放进wavePath字段进程号使用clDid
// Node node = finalNodeMap.get(item.getDeviceId());
// item.setLineId(Objects.isNull(node) ? null : node.getName());
// item.setWavePath(Objects.isNull(node) ? null : node.getIp());
// //事件等级(1:Ⅰ级||ERROR 2:Ⅱ级||WARN 3:Ⅲ级||(DEBUG&&NORMAL))
// if (item.getLevel() == 4 || item.getLevel() == 5) {
// item.setLevel(3);
// } else if (item.getLevel() == 6) {
// item.setLevel(2);
// } else if (item.getLevel() == 7) {
// item.setLevel(1);
// }
// BeanUtils.copyProperties(item, vo);
// frontWarnVos.add(vo);
// });
// result.setRecords(frontWarnVos);
// result.setTotal(page.getTotal());
// result.setPages(page.getPages());
// result.setCurrent(page.getCurrent());
// result.setSize(page.getSize());
// }
// return result;
// }
@Override @Override
public List<CsEventUserPO> queryEventListByUserId(String userIndex, List<String> eventList) { public List<CsEventUserPO> queryEventListByUserId(String userIndex, List<String> eventList) {
LambdaQueryWrapper<CsEventUserPO> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEventUserPO> queryWrapper = new LambdaQueryWrapper<>();

View File

@@ -1757,7 +1757,7 @@ public class DataServiceImpl implements IDataService {
if (CollUtil.isNotEmpty(result)) { if (CollUtil.isNotEmpty(result)) {
result.sort(Comparator.comparing(AppLineDetailVo::getProjectName) result.sort(Comparator.comparing(AppLineDetailVo::getProjectName)
.thenComparing(AppLineDetailVo::getDeviceName) .thenComparing(AppLineDetailVo::getDeviceName)
.thenComparing(AppLineDetailVo::getPointId)); .thenComparing(AppLineDetailVo::getPointName));
} }
return result; return result;
} }
@@ -2042,7 +2042,7 @@ public class DataServiceImpl implements IDataService {
children2.sort(Comparator.comparingInt(AppLineDetailVo.targetDetail::getSort)); children2.sort(Comparator.comparingInt(AppLineDetailVo.targetDetail::getSort));
children2.forEach(item2->{ children2.forEach(item2->{
if (Objects.isNull(item2.getData())) { if (Objects.isNull(item2.getData())) {
item2.setData(3.15159); item2.setData(3.14159);
} }
if (!Objects.equals(item2.getData(),NULL_DATA)) { if (!Objects.equals(item2.getData(),NULL_DATA)) {
item2.setData(BigDecimal.valueOf(item2.getData()).setScale(2, RoundingMode.HALF_UP).doubleValue()); item2.setData(BigDecimal.valueOf(item2.getData()).setScale(2, RoundingMode.HALF_UP).doubleValue());