feat(data): 添加指标别名功能并优化事件查询逻辑

- 在AppLineDetailVo中新增指标别名和其他名称单位字段
- 移除CsEventUserPOMapper.xml中的注释代码
- 重构事件查询SQL,使用CASE语句统一事件等级映射
- 更新事件查询条件,按等级重新分组过滤逻辑
- 优化DataServiceImpl中数据处理流程,增加空值检查和排序
- 添加对电压负序分量和零序分量的特殊处理
- 改进FTP服务实现,使用轮询机制替代固定延时
- 更新事件详情中的等级描述文档
This commit is contained in:
xy
2026-06-11 15:16:34 +08:00
parent 38be9f6839
commit 689f9ee51c
5 changed files with 84 additions and 93 deletions

View File

@@ -87,68 +87,6 @@
</select>
<!-- <select id="queryEventpage" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">-->
<!-- select DISTINCT a.event_id id,-->
<!-- <if test="flag">-->
<!-- a.status status,-->
<!-- </if>-->
<!-- <if test="!flag">-->
<!-- 1 status,-->
<!-- </if>-->
<!-- b.device_id deviceId,b.line_id lineId,b.code code,b.start_time startTime,b.amplitude,b.persist_time,-->
<!-- round(b.amplitude,2) evtParamVVaDepth,round(b.persist_time,2) evtParamTm,b.tag tag ,b.wave_path wavePath,b.phase evtParamPhase,b.location evtParamPosition,b.instant_pics,b.rms_pics , b.type type,b.level level,b.location location,d.name lineName-->
<!-- from cs_event_user a inner join cs_event b on a.event_id=b.id inner join cs_equipment_delivery c on b.device_id=c.id inner join cs_line d on d.device_id=b.device_id and d.clDid=b.cl_did where 1=1-->
<!-- and b.process=c.process-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.endTime != null and csEventUserQueryPage.endTime !=''">-->
<!-- AND DATE(b.start_time) &lt;= DATE(#{csEventUserQueryPage.endTime})-->
<!-- </if>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.startTime != null and csEventUserQueryPage.startTime !=''">-->
<!-- AND DATE(b.start_time) &gt;= DATE(#{csEventUserQueryPage.startTime})-->
<!-- </if>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.target != null and csEventUserQueryPage.target.size()>0">-->
<!-- and b.tag in-->
<!-- <foreach collection="csEventUserQueryPage.target" index="index" item="item" open="(" separator="," close=")">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- and b.device_id in-->
<!-- <foreach collection="devIds" index="index" item="item" open="(" separator="," close=")">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != null and csEventUserQueryPage.type !=''">-->
<!-- AND b.type =#{ csEventUserQueryPage.type}-->
<!-- </if>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''">-->
<!-- AND b.level IN-->
<!-- <foreach collection="csEventUserQueryPage.level.split(',')" item="level" open="(" separator="," close=")">-->
<!-- #{level}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.status != null and csEventUserQueryPage.status !=''">-->
<!-- AND a.status =#{ csEventUserQueryPage.status}-->
<!-- </if>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.userId != null and csEventUserQueryPage.userId !=''">-->
<!-- and a.user_id=#{ csEventUserQueryPage.userId}-->
<!-- </if>-->
<!-- <if test="csEventUserQueryPage!=null and csEventUserQueryPage.sortField != null">-->
<!-- <choose>-->
<!-- <when test="csEventUserQueryPage.sortField == 0">-->
<!-- order by b.start_time desc-->
<!-- </when>-->
<!-- <when test="csEventUserQueryPage.sortField == 1">-->
<!-- order by b.amplitude desc-->
<!-- </when>-->
<!-- <when test="csEventUserQueryPage.sortField == 2">-->
<!-- order by b.persist_time desc-->
<!-- </when>-->
<!-- <otherwise>-->
<!-- order by b.start_time desc-->
<!-- </otherwise>-->
<!-- </choose>-->
<!-- </if>-->
<!-- </select>-->
<select id="queryEventpage" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">
SELECT DISTINCT b.id,
b.device_id deviceId,
@@ -166,7 +104,13 @@
b.instant_pics,
b.rms_pics,
b.type type,
b.LEVEL LEVEL,
CASE
WHEN b.level = 4 THEN 3
WHEN b.level = 5 THEN 3
WHEN b.level = 6 THEN 2
WHEN b.level = 7 THEN 1
ELSE b.LEVEL
END AS level,
b.location location,
c.dev_type devType,
b.land_point landPoint,
@@ -210,10 +154,15 @@
</if>
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''">
AND b.level IN
<foreach collection="csEventUserQueryPage.level.split(',')" item="level" open="(" separator="," close=")">
#{level}
</foreach>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level == 1 ">
AND b.level IN (1,7)
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level == 2 ">
AND b.level IN (2,6)
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level == 3 ">
AND b.level IN (3)
</if>
</if>
<choose>
<when test="csEventUserQueryPage!=null and csEventUserQueryPage.sortField != null">
@@ -242,7 +191,15 @@
<select id="queryEventPageWeb" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">
select DISTINCT b.id id,
b.device_id deviceId,b.line_id lineId,b.code code,
b.start_time startTime,b.tag tag ,b.wave_path wavePath,b.instant_pics,b.rms_pics , b.type type,b.level level,b.location location,b.cl_did clDid
b.start_time startTime,b.tag tag ,b.wave_path wavePath,b.instant_pics,b.rms_pics , b.type type,
CASE
WHEN b.level = 4 THEN 3
WHEN b.level = 5 THEN 3
WHEN b.level = 6 THEN 2
WHEN b.level = 7 THEN 1
ELSE b.level
END AS level,
b.location location,b.cl_did clDid
,d.name lineName,b.advance_reason advanceReason,b.advance_type advanceType,b.sag_source sagSource,e.dev_type devType,b.severity severity,e.ndid nDid
from cs_event b
left join cs_line d on d.line_id=b.line_id
@@ -295,18 +252,22 @@
</foreach>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != null and csEventUserQueryPage.type !=''">
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type == 3 ">
AND b.type in(2,3)
AND b.type =#{ csEventUserQueryPage.type} and b.level in (1,2,3,6,7)
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != 3 ">
AND b.type =#{ csEventUserQueryPage.type}
AND b.type =#{ csEventUserQueryPage.type}
</if>
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''">
AND b.level IN
<foreach collection="csEventUserQueryPage.level.split(',')" item="level" open="(" separator="," close=")">
#{level}
</foreach>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level == 1 ">
AND b.level IN (1,7)
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level == 2 ">
AND b.level IN (2,6)
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level == 3 ">
AND b.level IN (3)
</if>
</if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.eventType != null and csEventUserQueryPage.eventType !=''">
AND b.tag = #{csEventUserQueryPage.eventType}

View File

@@ -169,7 +169,6 @@ public class DataServiceImpl implements IDataService {
//获取指标名称和对应的指标集合
List<CsStatisticalSetPO> csStatisticalSetPOList = csStatisticalSetFeignClient.queryStatisticalById(idList).getData();
Map<String,List<CsStatisticalSetPO>> csStatisticalSetPOMap = csStatisticalSetPOList.stream().collect(Collectors.groupingBy(CsStatisticalSetPO::getStatisicalId));
epdPqdMap.forEach((k,v) ->{
if (Objects.equals(map.get(k).getName(), "data_v")) {
partitions.forEach(l -> {
@@ -423,8 +422,12 @@ public class DataServiceImpl implements IDataService {
if (CollUtil.isEmpty(l1)) {
return;
}
List<EleEpdPqd> list1 = new ArrayList<>();
l1.forEach(item1 -> {
EleEpdPqd epdPqd = epdPqdMap2.get(item1.getTargetId());
list1.add(epdPqdMap2.get(item1.getTargetId()));
});
list1.sort(Comparator.comparingInt(EleEpdPqd::getSort));
list1.forEach(epdPqd -> {
AppLineDetailVo.targetDetail targetDetail = new AppLineDetailVo.targetDetail();
targetDetail.setTargetId(item3.getId());
targetDetail.setName(item3.getName());
@@ -432,6 +435,8 @@ public class DataServiceImpl implements IDataService {
targetDetail.setUnit(epdPqd.getUnit());
targetDetail.setSort(item3.getSort());
targetDetail.setPrimaryFormula(epdPqd.getPrimaryFormula());
targetDetail.setOtherName(epdPqd.getShowName());
targetDetail.setOtherNameUnit(epdPqd.getUnit());
if (Objects.equals(map.get(epdPqd.getClassId()).getName(), "data_v")) {
if (!Objects.isNull(epdPqd.getHarmStart()) && !Objects.isNull(epdPqd.getHarmEnd())) {
for (int i = epdPqd.getHarmStart(); i <= epdPqd.getHarmEnd(); i++) {
@@ -1493,8 +1498,15 @@ public class DataServiceImpl implements IDataService {
List<AppLineDetailVo.targetDetail> finalChildren = children2;
children.forEach(item3->{
List<CsStatisticalSetPO> l1 = csStatisticalSetPOMap.get(item3.getId());
if (CollUtil.isEmpty(l1)) {
return;
}
List<EleEpdPqd> list1 = new ArrayList<>();
l1.forEach(item1 -> {
EleEpdPqd epdPqd = epdPqdMap2.get(item1.getTargetId());
list1.add(epdPqdMap2.get(item1.getTargetId()));
});
list1.sort(Comparator.comparingInt(EleEpdPqd::getSort));
list1.forEach(epdPqd -> {
AppLineDetailVo.targetDetail targetDetail = new AppLineDetailVo.targetDetail();
targetDetail.setTargetId(item3.getId());
targetDetail.setName(item3.getName());
@@ -1798,6 +1810,9 @@ public class DataServiceImpl implements IDataService {
public void chanelData(List<AppLineDetailVo.targetDetail> finalChildren, String dataLevel1, String dataLevel2, Double pt, Double ct) {
finalChildren.forEach(item->{
if(Objects.equals(item.getOtherName(),"电压负序分量") || Objects.equals(item.getOtherName(),"电压零序分量")) {
return;
}
Double re;
String unit = item.getUnit();
@@ -1865,6 +1880,7 @@ public class DataServiceImpl implements IDataService {
}
}
item.setUnit(unit);
item.setOtherNameUnit(unit);
});
}
@@ -1949,8 +1965,14 @@ public class DataServiceImpl implements IDataService {
List<AppLineDetailVo.targetDetail> finalChildren = children2;
children.forEach(item3->{
List<CsStatisticalSetPO> l1 = csStatisticalSetPOMap.get(item3.getId());
if (CollUtil.isEmpty(l1)) {
return;
}
List<EleEpdPqd> list1 = new ArrayList<>();
l1.forEach(item1 -> {
EleEpdPqd epdPqd = epdPqdMap2.get(item1.getTargetId());
list1.add(epdPqdMap2.get(item1.getTargetId()));
});
list1.forEach(epdPqd -> {
AppLineDetailVo.targetDetail targetDetail = new AppLineDetailVo.targetDetail();
targetDetail.setTargetId(item3.getId());
targetDetail.setName(item3.getName());