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

@@ -51,11 +51,13 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
} }
redisUtil.delete(AppRedisKey.DEVICE_ROOT_PATH + nDid); redisUtil.delete(AppRedisKey.DEVICE_ROOT_PATH + nDid);
askDeviceDataFeignClient.askDeviceRootPath(nDid); askDeviceDataFeignClient.askDeviceRootPath(nDid);
Thread.sleep(3000); for (int i = 0; i <= 3; i++) {
Object object = redisUtil.getObjectByKey(AppRedisKey.DEVICE_ROOT_PATH + nDid); Thread.sleep(1000);
if (Objects.nonNull(object)) { Object object = redisUtil.getObjectByKey(AppRedisKey.DEVICE_ROOT_PATH + nDid);
makeUpVo.setPrjDataPath(object.toString()); if (Objects.nonNull(object)) {
makeUpVo.setType("dir"); makeUpVo.setPrjDataPath(object.toString());
makeUpVo.setType("dir");
}
} }
} catch (Exception e) { } catch (Exception e) {
throw new BusinessException(e.getMessage()); throw new BusinessException(e.getMessage());
@@ -75,12 +77,14 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
redisUtil.delete(AppRedisKey.PROJECT_INFO + nDid); redisUtil.delete(AppRedisKey.PROJECT_INFO + nDid);
// 请求设备文件或目录信息 // 请求设备文件或目录信息
askDeviceDataFeignClient.askDeviceFileOrDir(nDid, name); askDeviceDataFeignClient.askDeviceFileOrDir(nDid, name);
Thread.sleep(10000); for (int i = 0; i <= 10; i++) {
// 从 Redis 获取对象 Thread.sleep(1000);
Object object = redisUtil.getObjectByKey(AppRedisKey.PROJECT_INFO + nDid); // 从 Redis 获取对象
if (object != null) { Object object = redisUtil.getObjectByKey(AppRedisKey.PROJECT_INFO + nDid);
// 根据类型处理不同的数据 if (object != null) {
processObject(result, object, type); // 根据类型处理不同的数据
processObject(result, object, type);
}
} }
} catch (Exception e) { } catch (Exception e) {
// 捕获特定异常并抛出运行时异常 // 捕获特定异常并抛出运行时异常

View File

@@ -47,6 +47,12 @@ public class AppLineDetailVo implements Serializable {
@ApiModelProperty("指标名称") @ApiModelProperty("指标名称")
private String name; private String name;
@ApiModelProperty("指标别名")
private String otherName;
@ApiModelProperty("指标别名单位")
private String otherNameUnit;
@ApiModelProperty("单位") @ApiModelProperty("单位")
private String unit; private String unit;

View File

@@ -110,9 +110,7 @@ public class EventDetailVO {
* RMS波形图存在多张的情况 * RMS波形图存在多张的情况
*/ */
private String rmsPics; private String rmsPics;
@ApiModelProperty(value = " /**\n" + @ApiModelProperty(value = "事件等级(1:Ⅰ级||ERROR 2:Ⅱ级||WARN 3:Ⅲ级||(DEBUG&&NORMAL))")
" * 事件等级(1:Ⅰ级 2:Ⅱ级 3:Ⅲ级)\n" +
" */")
private String level; private String level;
/** /**

View File

@@ -87,68 +87,6 @@
</select> </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 id="queryEventpage" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">
SELECT DISTINCT b.id, SELECT DISTINCT b.id,
b.device_id deviceId, b.device_id deviceId,
@@ -166,7 +104,13 @@
b.instant_pics, b.instant_pics,
b.rms_pics, b.rms_pics,
b.type type, 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, b.location location,
c.dev_type devType, c.dev_type devType,
b.land_point landPoint, b.land_point landPoint,
@@ -210,10 +154,15 @@
</if> </if>
</if> </if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''">
AND b.level IN <if test="csEventUserQueryPage!=null and csEventUserQueryPage.level == 1 ">
<foreach collection="csEventUserQueryPage.level.split(',')" item="level" open="(" separator="," close=")"> AND b.level IN (1,7)
#{level} </if>
</foreach> <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>
<choose> <choose>
<when test="csEventUserQueryPage!=null and csEventUserQueryPage.sortField != null"> <when test="csEventUserQueryPage!=null and csEventUserQueryPage.sortField != null">
@@ -242,7 +191,15 @@
<select id="queryEventPageWeb" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO"> <select id="queryEventPageWeb" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">
select DISTINCT b.id id, select DISTINCT b.id id,
b.device_id deviceId,b.line_id lineId,b.code code, 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 ,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 from cs_event b
left join cs_line d on d.line_id=b.line_id left join cs_line d on d.line_id=b.line_id
@@ -295,18 +252,22 @@
</foreach> </foreach>
<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.type =#{ csEventUserQueryPage.type} and b.level in (1,2,3,6,7)
</if> </if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != 3 "> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != 3 ">
AND b.type =#{ csEventUserQueryPage.type} AND b.type =#{ csEventUserQueryPage.type}
</if> </if>
</if> </if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''">
AND b.level IN <if test="csEventUserQueryPage!=null and csEventUserQueryPage.level == 1 ">
<foreach collection="csEventUserQueryPage.level.split(',')" item="level" open="(" separator="," close=")"> AND b.level IN (1,7)
#{level} </if>
</foreach> <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>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.eventType != null and csEventUserQueryPage.eventType !=''"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.eventType != null and csEventUserQueryPage.eventType !=''">
AND b.tag = #{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(); List<CsStatisticalSetPO> csStatisticalSetPOList = csStatisticalSetFeignClient.queryStatisticalById(idList).getData();
Map<String,List<CsStatisticalSetPO>> csStatisticalSetPOMap = csStatisticalSetPOList.stream().collect(Collectors.groupingBy(CsStatisticalSetPO::getStatisicalId)); Map<String,List<CsStatisticalSetPO>> csStatisticalSetPOMap = csStatisticalSetPOList.stream().collect(Collectors.groupingBy(CsStatisticalSetPO::getStatisicalId));
epdPqdMap.forEach((k,v) ->{ epdPqdMap.forEach((k,v) ->{
if (Objects.equals(map.get(k).getName(), "data_v")) { if (Objects.equals(map.get(k).getName(), "data_v")) {
partitions.forEach(l -> { partitions.forEach(l -> {
@@ -423,8 +422,12 @@ public class DataServiceImpl implements IDataService {
if (CollUtil.isEmpty(l1)) { if (CollUtil.isEmpty(l1)) {
return; return;
} }
List<EleEpdPqd> list1 = new ArrayList<>();
l1.forEach(item1 -> { 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(); AppLineDetailVo.targetDetail targetDetail = new AppLineDetailVo.targetDetail();
targetDetail.setTargetId(item3.getId()); targetDetail.setTargetId(item3.getId());
targetDetail.setName(item3.getName()); targetDetail.setName(item3.getName());
@@ -432,6 +435,8 @@ public class DataServiceImpl implements IDataService {
targetDetail.setUnit(epdPqd.getUnit()); targetDetail.setUnit(epdPqd.getUnit());
targetDetail.setSort(item3.getSort()); targetDetail.setSort(item3.getSort());
targetDetail.setPrimaryFormula(epdPqd.getPrimaryFormula()); targetDetail.setPrimaryFormula(epdPqd.getPrimaryFormula());
targetDetail.setOtherName(epdPqd.getShowName());
targetDetail.setOtherNameUnit(epdPqd.getUnit());
if (Objects.equals(map.get(epdPqd.getClassId()).getName(), "data_v")) { if (Objects.equals(map.get(epdPqd.getClassId()).getName(), "data_v")) {
if (!Objects.isNull(epdPqd.getHarmStart()) && !Objects.isNull(epdPqd.getHarmEnd())) { if (!Objects.isNull(epdPqd.getHarmStart()) && !Objects.isNull(epdPqd.getHarmEnd())) {
for (int i = epdPqd.getHarmStart(); i <= epdPqd.getHarmEnd(); i++) { for (int i = epdPqd.getHarmStart(); i <= epdPqd.getHarmEnd(); i++) {
@@ -1493,8 +1498,15 @@ public class DataServiceImpl implements IDataService {
List<AppLineDetailVo.targetDetail> finalChildren = children2; List<AppLineDetailVo.targetDetail> finalChildren = children2;
children.forEach(item3->{ children.forEach(item3->{
List<CsStatisticalSetPO> l1 = csStatisticalSetPOMap.get(item3.getId()); List<CsStatisticalSetPO> l1 = csStatisticalSetPOMap.get(item3.getId());
if (CollUtil.isEmpty(l1)) {
return;
}
List<EleEpdPqd> list1 = new ArrayList<>();
l1.forEach(item1 -> { 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(); AppLineDetailVo.targetDetail targetDetail = new AppLineDetailVo.targetDetail();
targetDetail.setTargetId(item3.getId()); targetDetail.setTargetId(item3.getId());
targetDetail.setName(item3.getName()); 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) { public void chanelData(List<AppLineDetailVo.targetDetail> finalChildren, String dataLevel1, String dataLevel2, Double pt, Double ct) {
finalChildren.forEach(item->{ finalChildren.forEach(item->{
if(Objects.equals(item.getOtherName(),"电压负序分量") || Objects.equals(item.getOtherName(),"电压零序分量")) {
return;
}
Double re; Double re;
String unit = item.getUnit(); String unit = item.getUnit();
@@ -1865,6 +1880,7 @@ public class DataServiceImpl implements IDataService {
} }
} }
item.setUnit(unit); item.setUnit(unit);
item.setOtherNameUnit(unit);
}); });
} }
@@ -1949,8 +1965,14 @@ public class DataServiceImpl implements IDataService {
List<AppLineDetailVo.targetDetail> finalChildren = children2; List<AppLineDetailVo.targetDetail> finalChildren = children2;
children.forEach(item3->{ children.forEach(item3->{
List<CsStatisticalSetPO> l1 = csStatisticalSetPOMap.get(item3.getId()); List<CsStatisticalSetPO> l1 = csStatisticalSetPOMap.get(item3.getId());
if (CollUtil.isEmpty(l1)) {
return;
}
List<EleEpdPqd> list1 = new ArrayList<>();
l1.forEach(item1 -> { l1.forEach(item1 -> {
EleEpdPqd epdPqd = epdPqdMap2.get(item1.getTargetId()); list1.add(epdPqdMap2.get(item1.getTargetId()));
});
list1.forEach(epdPqd -> {
AppLineDetailVo.targetDetail targetDetail = new AppLineDetailVo.targetDetail(); AppLineDetailVo.targetDetail targetDetail = new AppLineDetailVo.targetDetail();
targetDetail.setTargetId(item3.getId()); targetDetail.setTargetId(item3.getId());
targetDetail.setName(item3.getName()); targetDetail.setName(item3.getName());