0918优化-点位列表电池簇特殊处理
This commit is contained in:
@ -118,9 +118,16 @@ public interface EmsPointMatchMapper
|
||||
@Param("endDate")Date endDate,
|
||||
@Param("deviceId")String deviceId);
|
||||
|
||||
// 单个站点单个设备点位查询
|
||||
// 单个站点单个设备点位查询-除了电池簇其他设备使用
|
||||
public List<PointQueryResponse> getSingleSiteDevicePoints(@Param("siteId")String siteId,
|
||||
@Param("deviceCategory")String deviceCategory,
|
||||
@Param("dataPointName")String dataPointName,
|
||||
@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);
|
||||
}
|
||||
|
||||
@ -127,13 +127,16 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
|
||||
String deviceId = request.getDeviceId();
|
||||
String deviceCategory = request.getDeviceCategory();
|
||||
|
||||
List<PointQueryResponse> response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory,
|
||||
request.getDataPointName(),request.getDataPoint());
|
||||
List<PointQueryResponse> response = new ArrayList<>();
|
||||
|
||||
|
||||
// 电动所的电池簇特殊处理-来源pcs+bmsd
|
||||
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 {
|
||||
response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory,
|
||||
request.getDataPointName(),request.getDataPoint());
|
||||
// 从redis取最新数据
|
||||
JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId);
|
||||
if(mqttJson == null){
|
||||
@ -166,24 +169,23 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
|
||||
BigDecimal lowerBound = request.getLower();
|
||||
BigDecimal upperBound = request.getUpper();
|
||||
// 数据反向筛选
|
||||
if (lowerBound == null && upperBound == null) {
|
||||
return response;
|
||||
if (lowerBound != null || upperBound != null) {
|
||||
response = response.stream() .filter(point -> {
|
||||
Object dataValue = point.getPointValue();
|
||||
if (dataValue == null) {
|
||||
return false;
|
||||
}
|
||||
// 转换为BigDecimal进行精确比较(避免double精度损失)
|
||||
BigDecimal value = parseToBigDecimal(dataValue);
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
// 比较:使用BigDecimal的compareTo方法
|
||||
boolean meetLower = (lowerBound == null) || (value.compareTo(lowerBound) >= 0);
|
||||
boolean meetUpper = (upperBound == null) || (value.compareTo(upperBound) <= 0);
|
||||
return meetLower && meetUpper;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
response = response.stream() .filter(point -> {
|
||||
Object dataValue = point.getPointValue();
|
||||
if (dataValue == null) {
|
||||
return false;
|
||||
}
|
||||
// 转换为BigDecimal进行精确比较(避免double精度损失)
|
||||
BigDecimal value = parseToBigDecimal(dataValue);
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
// 比较:使用BigDecimal的compareTo方法
|
||||
boolean meetLower = (lowerBound == null) || (value.compareTo(lowerBound) >= 0);
|
||||
boolean meetUpper = (upperBound == null) || (value.compareTo(upperBound) <= 0);
|
||||
return meetLower && meetUpper;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 结果排序
|
||||
String sortMethod = request.getSortMethod();
|
||||
@ -213,7 +215,15 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
|
||||
}
|
||||
|
||||
// 对于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();
|
||||
|
||||
// 数据来源pcs
|
||||
@ -223,7 +233,6 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
|
||||
mergedData.putAll(data);
|
||||
}
|
||||
// 根据deviceId获取父类bmsd
|
||||
String bmsdDeviceId = deviceId.replace("BMSC","BMSD");
|
||||
JSONObject bmsdJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + bmsdDeviceId);
|
||||
if (bmsdJson != null) {
|
||||
JSONObject data = bmsdJson.getJSONObject("Data");
|
||||
|
||||
Reference in New Issue
Block a user