|
|
|
@ -15,6 +15,7 @@ import com.ruoyi.tdengine.api.domain.TdField;
|
|
|
|
|
import com.ruoyi.tdengine.api.domain.TdHistorySelectDto;
|
|
|
|
|
import com.ruoyi.tdengine.api.domain.TdReturnDataVo;
|
|
|
|
|
import com.ruoyi.tdengine.api.domain.TdSuperTableSelectVo;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
@ -52,11 +53,12 @@ public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService {
|
|
|
|
|
JSONObject returnObj = new JSONObject();
|
|
|
|
|
Long deviceModeId = deviceLatestDataVo.getDeviceModeId();
|
|
|
|
|
HwDeviceModeFunction queryModeFunction = new HwDeviceModeFunction();
|
|
|
|
|
queryModeFunction.setDeviceModeId(deviceModeId);
|
|
|
|
|
queryModeFunction.setFunctionMode(HwDictConstants.FUNCTION_MODE_ATTRIBUTE);
|
|
|
|
|
queryModeFunction.setDeviceModeId(deviceModeId);//索引,先查出数据再过滤
|
|
|
|
|
// queryModeFunction.setFunctionMode(HwDictConstants.FUNCTION_MODE_ATTRIBUTE);
|
|
|
|
|
List<HwDeviceModeFunction> deviceModeFunctions = deviceModeFunctionMapper.selectHwDeviceModeFunctionList(queryModeFunction);
|
|
|
|
|
Map<String, String> functionIndentifierName = deviceModeFunctions.stream().collect(
|
|
|
|
|
Collectors.toMap(HwDeviceModeFunction::getFunctionIdentifier, HwDeviceModeFunction::getFunctionName));
|
|
|
|
|
Map<String, String> functionIndentifierName = deviceModeFunctions.stream()
|
|
|
|
|
.filter(deviceModeFunction -> deviceModeFunction.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE) && !deviceModeFunction.getDisplayFlag().equals(HwDictConstants.DEVICE_MODE_FUNCTION_DISPLAY_FLAG_NO))
|
|
|
|
|
.collect(Collectors.toMap(HwDeviceModeFunction::getFunctionIdentifier, HwDeviceModeFunction::getFunctionName));
|
|
|
|
|
functionIndentifierName.putAll(TdEngineConstants.DEVICE_DATA_COLUMN_MAP);
|
|
|
|
|
|
|
|
|
|
Map<String, String> functionIndentifierNameMap = new HashMap<>();
|
|
|
|
@ -84,7 +86,6 @@ public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService {
|
|
|
|
|
tdSuperTableSelectVo.setLimit(deviceLatestDataVo.getLimit());
|
|
|
|
|
|
|
|
|
|
List<TdField> schemaFieldValues = new ArrayList<TdField>();
|
|
|
|
|
List<HwDeviceModeFunction> modeFunctions = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
deviceModeFunctions.forEach(mf -> {
|
|
|
|
|
TdField field = new TdField();
|
|
|
|
@ -101,16 +102,23 @@ public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<DeviceDataColumnVo> deviceDataColumnVos = new ArrayList<DeviceDataColumnVo>();
|
|
|
|
|
if (latestDataMaps != null && latestDataMaps.size() > 0) {
|
|
|
|
|
Map<String, Object> latestDataMap = latestDataMaps.get(0);
|
|
|
|
|
for (Map.Entry<String, Object> entry : latestDataMap.entrySet()) {
|
|
|
|
|
// Map<String, Object> latestDataMap = latestDataMaps.get(0);
|
|
|
|
|
for (Map.Entry<String, String> entry : functionIndentifierNameMap.entrySet()) {
|
|
|
|
|
DeviceDataColumnVo deviceDataColumnVo = new DeviceDataColumnVo();
|
|
|
|
|
String columnKey = entry.getKey();
|
|
|
|
|
if (!columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICEID)
|
|
|
|
|
&& !columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICEMODEID)) {
|
|
|
|
|
&& !columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICEMODEID)
|
|
|
|
|
&& functionIndentifierNameMap.get(columnKey) != null) {
|
|
|
|
|
deviceDataColumnVo.setColumnKey(columnKey);
|
|
|
|
|
deviceDataColumnVo.setColumnName(functionIndentifierNameMap.get(columnKey) == null
|
|
|
|
|
? columnKey : functionIndentifierNameMap.get(columnKey));
|
|
|
|
|
if (columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICECODE)) {
|
|
|
|
|
deviceDataColumnVos.add(0, deviceDataColumnVo);
|
|
|
|
|
} else if (columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICENAME)) {
|
|
|
|
|
deviceDataColumnVos.add(1, deviceDataColumnVo);
|
|
|
|
|
} else if (columnKey.equalsIgnoreCase(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME)) {
|
|
|
|
|
deviceDataColumnVos.add(2, deviceDataColumnVo);
|
|
|
|
|
} else {
|
|
|
|
|
deviceDataColumnVos.add(deviceDataColumnVo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -157,33 +165,35 @@ public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService {
|
|
|
|
|
* @date 2023-09-25 15:40
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<DeviceDataColumnVo> getDeviceDataColumns(Long deviceModeId, List<Map<String, Object>> latestDataMaps) {
|
|
|
|
|
public List<DeviceDataColumnVo> getDeviceDataColumns(Long deviceModeId) {
|
|
|
|
|
HwDeviceModeFunction queryModeFunction = new HwDeviceModeFunction();
|
|
|
|
|
queryModeFunction.setDeviceModeId(deviceModeId);
|
|
|
|
|
queryModeFunction.setFunctionMode(HwDictConstants.FUNCTION_MODE_ATTRIBUTE);
|
|
|
|
|
queryModeFunction.setDeviceModeId(deviceModeId);//devicemodeid是索引,先根据索引查出再过滤
|
|
|
|
|
// queryModeFunction.setFunctionMode(HwDictConstants.FUNCTION_MODE_ATTRIBUTE);
|
|
|
|
|
List<HwDeviceModeFunction> deviceModeFunctions = deviceModeFunctionMapper.selectHwDeviceModeFunctionList(queryModeFunction);
|
|
|
|
|
Map<String, String> functionIndentifierName = deviceModeFunctions.stream().collect(
|
|
|
|
|
Collectors.toMap(HwDeviceModeFunction::getFunctionIdentifier, HwDeviceModeFunction::getFunctionName));
|
|
|
|
|
functionIndentifierName.putAll(TdEngineConstants.DEVICE_DATA_COLUMN_MAP);
|
|
|
|
|
functionIndentifierName.putAll(TdEngineConstants.DEVICE_DATA_COLUMN_MAP);
|
|
|
|
|
|
|
|
|
|
Map<String, String> functionIndentifierNameMap = new HashMap<>();
|
|
|
|
|
functionIndentifierName.forEach((key, val) ->
|
|
|
|
|
//key是functionidentifier,用来获取具体值使用;value是functionname,用来显示使用
|
|
|
|
|
Map<String, String> functionIndentifierNameMap = deviceModeFunctions.stream().
|
|
|
|
|
filter(deviceModeFunction -> deviceModeFunction.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE) && !deviceModeFunction.getDisplayFlag().equals(HwDictConstants.DEVICE_MODE_FUNCTION_DISPLAY_FLAG_NO))
|
|
|
|
|
.collect(Collectors.toMap(HwDeviceModeFunction::getFunctionIdentifier, HwDeviceModeFunction::getFunctionName));
|
|
|
|
|
functionIndentifierNameMap.put(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME, TdEngineConstants.DEFAULT_FIRST_FIELD_NAME_DISPLAY);
|
|
|
|
|
// functionIndentifierName.putAll(TdEngineConstants.DEVICE_DATA_COLUMN_MAP);
|
|
|
|
|
|
|
|
|
|
Map<String, String> functionIndentifierNameTransferMap = new HashMap<>();
|
|
|
|
|
functionIndentifierNameMap.forEach((key, val) ->
|
|
|
|
|
{
|
|
|
|
|
String keyTransfer = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key) == null ?
|
|
|
|
|
key : TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key);
|
|
|
|
|
functionIndentifierNameMap.put(keyTransfer, val);
|
|
|
|
|
functionIndentifierNameTransferMap.put(keyTransfer, val);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
List<DeviceDataColumnVo> deviceDataColumnVos = new ArrayList<DeviceDataColumnVo>();
|
|
|
|
|
if (latestDataMaps != null && latestDataMaps.size() > 0) {
|
|
|
|
|
Map<String, Object> latestDataMap = latestDataMaps.get(0);
|
|
|
|
|
for (Map.Entry<String, Object> entry : latestDataMap.entrySet()) {
|
|
|
|
|
DeviceDataColumnVo deviceDataColumnVo = new DeviceDataColumnVo();
|
|
|
|
|
List<DeviceDataColumnVo> deviceDataColumnVos = new ArrayList<>();
|
|
|
|
|
if (functionIndentifierNameTransferMap != null) {
|
|
|
|
|
DeviceDataColumnVo deviceDataColumnVo = null;
|
|
|
|
|
for (Map.Entry<String, String> entry : functionIndentifierNameTransferMap.entrySet()) {
|
|
|
|
|
deviceDataColumnVo = new DeviceDataColumnVo();
|
|
|
|
|
String columnKey = entry.getKey();
|
|
|
|
|
deviceDataColumnVo.setColumnKey(columnKey);
|
|
|
|
|
deviceDataColumnVo.setColumnName(functionIndentifierNameMap.get(columnKey) == null
|
|
|
|
|
? columnKey : functionIndentifierNameMap.get(columnKey));
|
|
|
|
|
deviceDataColumnVo.setColumnName(StringUtils.isEmpty(functionIndentifierNameTransferMap.get(columnKey))
|
|
|
|
|
? columnKey : functionIndentifierNameTransferMap.get(columnKey));
|
|
|
|
|
deviceDataColumnVos.add(deviceDataColumnVo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|