dev #2

Merged
dashixiong merged 349 commits from dev into main 2026-02-11 01:55:46 +00:00
241 changed files with 27511 additions and 1024 deletions
Showing only changes of commit 7cd5a9b131 - Show all commits

View File

@ -147,10 +147,11 @@ public class EmsSiteConfigController extends BaseController{
*/
@GetMapping("/getDevicePointList")
public TableDataInfo getDevicePointList(@RequestParam String siteId,@RequestParam String deviceId,
@RequestParam String deviceCategory, String dataPointName,
String dataPoint)
@RequestParam String deviceCategory, String sortMethod,
String dataPointName, String dataPoint)
{
List<PointQueryResponse> result = iEmsDeviceSettingService.getSingleSiteDevicePoints(siteId,deviceId,deviceCategory,dataPointName,dataPoint);
List<PointQueryResponse> result = iEmsDeviceSettingService.getSingleSiteDevicePoints(
siteId,deviceId,deviceCategory,dataPointName,dataPoint,sortMethod);
return getDataTable2(result);
}
}

View File

@ -25,5 +25,5 @@ public interface IEmsDeviceSettingService
public List<DeviceCategory> getDeviceCategory();
public List<PointQueryResponse> getSingleSiteDevicePoints(String siteId, String deviceId, String deviceCategory,
String dataPointName, String dataPoint);
String dataPointName, String dataPoint, String sortMethod);
}

View File

@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* 站点信息 服务层实现
@ -120,41 +121,49 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
@Override
public List<PointQueryResponse> getSingleSiteDevicePoints(String siteId, String deviceId,
String deviceCategory, String dataPointName,String dataPoint) {
String deviceCategory, String dataPointName,
String dataPoint, String sortMethod) {
List<PointQueryResponse> response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory,dataPointName,dataPoint);
// 电动所的电池簇特殊处理-来源pcs+bmsd
if (siteId.equals(DDS_SITE_ID) && DeviceCategory.CLUSTER.getCode().equals(deviceCategory)) {
response = specialDealWithDDSCluster(response,siteId,deviceId);
return response;
}
// 从redis取最新数据
//String test = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId);
JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId);
if(mqttJson == null){
return response;
}
String deviceFromMqtt = mqttJson.get("Device").toString();
String jsonData = mqttJson.get("Data").toString();
if (StringUtils.isEmpty(jsonData) || !deviceId.equals(deviceFromMqtt)) {
return response;
}
Map<String, Object> obj = JSON.parseObject(jsonData, new TypeReference<Map<String, Object>>() {});
for (PointQueryResponse pointInfo : response) {
String dataKey = pointInfo.getDataPoint();
int isNeedDeviceId = pointInfo.getIsNeedDeviceId();
if (isNeedDeviceId == 1) {// 需要根据deviceId拼接point
dataKey = deviceId + dataKey;
pointInfo.setDataPoint(dataKey);
} else {
// 从redis取最新数据
JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId);
if(mqttJson == null){
return response;
}
String deviceFromMqtt = mqttJson.get("Device").toString();
String jsonData = mqttJson.get("Data").toString();
if (StringUtils.isEmpty(jsonData) || !deviceId.equals(deviceFromMqtt)) {
return response;
}
Map<String, Object> obj = JSON.parseObject(jsonData, new TypeReference<Map<String, Object>>() {});
for (PointQueryResponse pointInfo : response) {
String dataKey = pointInfo.getDataPoint();
int isNeedDeviceId = pointInfo.getIsNeedDeviceId();
if (isNeedDeviceId == 1) {// 需要根据deviceId拼接point
dataKey = deviceId + dataKey;
pointInfo.setDataPoint(dataKey);
}
pointInfo.setPointValue(obj.get(dataKey));
Long updateTime = Long.valueOf(mqttJson.get("timestamp").toString());
Date latestUpdateTime = convertUpdateTime(updateTime);
pointInfo.setUpdateTime(latestUpdateTime);
}
pointInfo.setPointValue(obj.get(dataKey));
Long updateTime = Long.valueOf(mqttJson.get("timestamp").toString());
Date latestUpdateTime = convertUpdateTime(updateTime);
pointInfo.setUpdateTime(latestUpdateTime);
}
if (response == null || response.isEmpty()) {
return response;
}
// 结果排序
if (sortMethod==null || sortMethod.isEmpty() || "asc".equals(sortMethod)) {// 升序
response = response.stream().sorted(Comparator.comparing(PointQueryResponse::getUpdateTime)).collect(Collectors.toList());
} else if ("desc".equals(sortMethod)) {//降序
response = response.stream().sorted(Comparator.comparing(PointQueryResponse::getUpdateTime).reversed()).collect(Collectors.toList());
}
return response;
}