dev #2
@ -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");
|
||||
|
||||
@ -339,4 +339,34 @@
|
||||
and t.data_point like CONCAT('%', #{dataPoint}, '%')
|
||||
</if>
|
||||
</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>
|
||||
Reference in New Issue
Block a user