0918优化-点位列表电池簇特殊处理

This commit is contained in:
2025-09-26 16:37:46 +08:00
parent 553e30c6ef
commit b2d5023122
3 changed files with 69 additions and 23 deletions

View File

@ -118,9 +118,16 @@ public interface EmsPointMatchMapper
@Param("endDate")Date endDate, @Param("endDate")Date endDate,
@Param("deviceId")String deviceId); @Param("deviceId")String deviceId);
// 单个站点单个设备点位查询 // 单个站点单个设备点位查询-除了电池簇其他设备使用
public List<PointQueryResponse> getSingleSiteDevicePoints(@Param("siteId")String siteId, public List<PointQueryResponse> getSingleSiteDevicePoints(@Param("siteId")String siteId,
@Param("deviceCategory")String deviceCategory, @Param("deviceCategory")String deviceCategory,
@Param("dataPointName")String dataPointName, @Param("dataPointName")String dataPointName,
@Param("dataPoint")String dataPoint); @Param("dataPoint")String dataPoint);
// 单个站点单个设备点位查询-电池簇使用
public List<PointQueryResponse> getClusterDevicePoints(@Param("siteId")String siteId,
@Param("deviceId")String deviceId,
@Param("parentDeviceId")String parentDeviceId,
@Param("deviceCategory")String deviceCategory,
@Param("dataPointName")String dataPointName,
@Param("dataPoint")String dataPoint);
} }

View File

@ -127,13 +127,16 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
String deviceId = request.getDeviceId(); String deviceId = request.getDeviceId();
String deviceCategory = request.getDeviceCategory(); String deviceCategory = request.getDeviceCategory();
List<PointQueryResponse> response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory, List<PointQueryResponse> response = new ArrayList<>();
request.getDataPointName(),request.getDataPoint());
// 电动所的电池簇特殊处理-来源pcs+bmsd // 电动所的电池簇特殊处理-来源pcs+bmsd
if (siteId.equals(DDS_SITE_ID) && DeviceCategory.CLUSTER.getCode().equals(deviceCategory)) { if (siteId.equals(DDS_SITE_ID) && DeviceCategory.CLUSTER.getCode().equals(deviceCategory)) {
response = specialDealWithDDSCluster(response,siteId,deviceId); response = specialDealWithDDSCluster(siteId,deviceId,deviceCategory,
request.getDataPointName(),request.getDataPoint());
} else { } else {
response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory,
request.getDataPointName(),request.getDataPoint());
// 从redis取最新数据 // 从redis取最新数据
JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId); JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId);
if(mqttJson == null){ if(mqttJson == null){
@ -166,9 +169,7 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
BigDecimal lowerBound = request.getLower(); BigDecimal lowerBound = request.getLower();
BigDecimal upperBound = request.getUpper(); BigDecimal upperBound = request.getUpper();
// 数据反向筛选 // 数据反向筛选
if (lowerBound == null && upperBound == null) { if (lowerBound != null || upperBound != null) {
return response;
}
response = response.stream() .filter(point -> { response = response.stream() .filter(point -> {
Object dataValue = point.getPointValue(); Object dataValue = point.getPointValue();
if (dataValue == null) { if (dataValue == null) {
@ -184,6 +185,7 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
boolean meetUpper = (upperBound == null) || (value.compareTo(upperBound) <= 0); boolean meetUpper = (upperBound == null) || (value.compareTo(upperBound) <= 0);
return meetLower && meetUpper; return meetLower && meetUpper;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
}
// 结果排序 // 结果排序
String sortMethod = request.getSortMethod(); String sortMethod = request.getSortMethod();
@ -213,7 +215,15 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
} }
// 对于dds的电池簇点位最新数据获取特殊处理 // 对于dds的电池簇点位最新数据获取特殊处理
private List<PointQueryResponse> specialDealWithDDSCluster(List<PointQueryResponse> response, String siteId, String deviceId) { private List<PointQueryResponse> specialDealWithDDSCluster(String siteId, String deviceId, String deviceCategory,
String dataPointName, String dataPoint) {
// 替换为对应的父类id
String bmsdDeviceId = deviceId.replace("BMSC","BMSD");
List<PointQueryResponse> response = emsPointMatchMapper
.getClusterDevicePoints(siteId,deviceId,bmsdDeviceId,deviceCategory,dataPointName,dataPoint);
JSONObject mergedData = new JSONObject(); JSONObject mergedData = new JSONObject();
// 数据来源pcs // 数据来源pcs
@ -223,7 +233,6 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
mergedData.putAll(data); mergedData.putAll(data);
} }
// 根据deviceId获取父类bmsd // 根据deviceId获取父类bmsd
String bmsdDeviceId = deviceId.replace("BMSC","BMSD");
JSONObject bmsdJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + bmsdDeviceId); JSONObject bmsdJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + bmsdDeviceId);
if (bmsdJson != null) { if (bmsdJson != null) {
JSONObject data = bmsdJson.getJSONObject("Data"); JSONObject data = bmsdJson.getJSONObject("Data");

View File

@ -339,4 +339,34 @@
and t.data_point like CONCAT('%', #{dataPoint}, '%') and t.data_point like CONCAT('%', #{dataPoint}, '%')
</if> </if>
</select> </select>
<select id="getClusterDevicePoints" resultType="com.xzzn.ems.domain.vo.PointQueryResponse">
SELECT tmp.pointName,
tmp.dataPoint,
tmp.dataDevice,
tmp.dataPointName
FROM ( select t.point_name as pointName,
case
when t.need_diff_device_id = 1 and t.data_device = 'PCS' then concat(#{deviceId}, t.data_point)
when t.need_diff_device_id = 1 and t.data_device = 'BMSD' then concat(#{parentDeviceId}, t.data_point)
else t.data_point end as dataPoint,
t.data_point_name as dataPointName,
t.data_device as dataDevice
from ems_point_match t
where 1=1
<if test="siteId != null and siteId != ''">
and t.site_id = #{siteId}
</if>
<if test="deviceCategory != null and deviceCategory != ''">
and t.device_category = #{deviceCategory}
</if>
) as tmp
where 1=1
<if test="dataPointName != null and dataPointName != ''">
and tmp.dataPointName like CONCAT('%', #{dataPointName}, '%')
</if>
<if test="dataPoint != null and dataPoint != ''">
and tmp.dataPoint like CONCAT('%', #{dataPoint}, '%')
</if>
</select>
</mapper> </mapper>