@ -424,159 +424,318 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
* /
@Override
public Map < String , List < HwDeviceVo > > getDevicesByMonitor ( HwDevice queryHwDevice ) {
Map < String , List < HwDeviceVo > > devicesMap = new HashMap < String , List < HwDeviceVo > > ( ) ;
List < HwDeviceVo > controlDeviceVos = new ArrayList < HwDeviceVo > ( ) ;
List < HwDeviceVo > acquisitionDeviceVos = new ArrayList < HwDeviceVo > ( ) ;
String databaseName = TdEngineConstants . getDatabaseName ( ) ;
try {
Map < String , List < HwDeviceVo > > devicesMap = new HashMap < > ( ) ;
List < HwDeviceVo > controlDeviceVos = new ArrayList < > ( ) ;
List < HwDeviceVo > acquisitionDeviceVos = new ArrayList < > ( ) ;
String databaseName = TdEngineConstants . getDatabaseName ( ) ;
List < HwDevice > hwDevices = hwDeviceMapper . selectHwDeviceListByMonitor ( queryHwDevice ) ;
List < HwDevice > hwDevices = hwDeviceMapper . selectHwDeviceListByMonitor ( queryHwDevice ) ;
/* 获取该监控单元节点下的所有子孙节点的设备 */
//获取所有监控单元
List < HwMonitorUnit > hwMonitorUnits = hwMonitorUnitMapper . selectHwMonitorUnitList ( new HwMonitorUnit ( ) ) ;
Long targetNodeId = queryHwDevice . getMonitorUnitId ( ) ; //目标节点,即父节点ID
//TODO( zangch, 2024.10.16) : 在hwDevices拼接子孙节点的设备列表, 数据库样本少未完全验证性能和有效性
//调用递归方法
List < HwMonitorUnit > descendants = getAllHwMonitorUnits ( hwMonitorUnits , targetNodeId ) ;
// 遍历所有监控单元
for ( HwMonitorUnit hwMonitorUnit : descendants ) {
// 创建设备对象
HwDevice hwMonitorUnitDevice = new HwDevice ( ) ;
// 设置监控单元ID
hwMonitorUnitDevice . setMonitorUnitId ( hwMonitorUnit . getMonitorUnitId ( ) ) ;
// 根据监控单元ID查询设备列表
List < HwDevice > hwDevicesByMonitor = hwDeviceMapper . selectHwDeviceListByMonitor ( hwMonitorUnitDevice ) ;
// 将查询到的设备列表添加到总列表中
hwDevices . addAll ( hwDevicesByMonitor ) ;
}
/* 获取该监控单元节点下的所有子孙节点的设备 */
List < HwMonitorUnit > hwMonitorUnits = hwMonitorUnitMapper . selectHwMonitorUnitList ( new HwMonitorUnit ( ) ) ;
Long targetNodeId = queryHwDevice . getMonitorUnitId ( ) ;
List < HwMonitorUnit > descendants = getAllHwMonitorUnits ( hwMonitorUnits , targetNodeId ) ;
if ( hwDevices . size ( ) > 0 ) {
hwDevices . forEach ( hwDevice - > {
Long deviceId = hwDevice . getDeviceId ( ) ;
HwDeviceModeFunction queryDeviceModeFunction = new HwDeviceModeFunction ( ) ;
queryDeviceModeFunction . setDeviceModeId ( hwDevice . getDeviceModeId ( ) ) ;
List < HwDeviceModeFunction > deviceModeFunctions = hwDevieModeFunctionMapper . selectHwDeviceModeFunctionList ( queryDeviceModeFunction ) ;
for ( HwMonitorUnit hwMonitorUnit : descendants ) {
HwDevice hwMonitorUnitDevice = new HwDevice ( ) ;
hwMonitorUnitDevice . setMonitorUnitId ( hwMonitorUnit . getMonitorUnitId ( ) ) ;
List < HwDevice > hwDevicesByMonitor = hwDeviceMapper . selectHwDeviceListByMonitor ( hwMonitorUnitDevice ) ;
hwDevices . addAll ( hwDevicesByMonitor ) ;
}
String tableName = TdEngineConstants . getDeviceDataTableName ( deviceId ) ;
TdSelectDto tdSelectDto = new TdSelectDto ( ) ;
tdSelectDto . setDatabaseName ( databaseName ) ;
tdSelectDto . setTableName ( tableName ) ;
List < TdField > schemaFieldValues = new ArrayList < TdField > ( ) ;
List < HwDeviceModeFunction > modeFunctions = new ArrayList < > ( ) ;
if ( hwDevices ! = null & & ! hwDevices . isEmpty ( ) ) {
for ( HwDevice hwDevice : hwDevices ) {
Long deviceId = hwDevice . getDeviceId ( ) ;
HwDeviceModeFunction queryDeviceModeFunction = new HwDeviceModeFunction ( ) ;
queryDeviceModeFunction . setDeviceModeId ( hwDevice . getDeviceModeId ( ) ) ;
List < HwDeviceModeFunction > deviceModeFunctions =
hwDevieModeFunctionMapper . selectHwDeviceModeFunctionList ( queryDeviceModeFunction ) ;
deviceModeFunctions . forEach ( mf - > {
//是属性的,并且是可显示的
if ( mf . getFunctionMode ( ) . equals ( HwDictConstants . FUNCTION_MODE_ATTRIBUTE )
& & ! mf . getDisplayFlag ( ) . equals ( HwDictConstants . DEVICE_MODE_FUNCTION_DISPLAY_FLAG_NO ) ) {
TdField field = new TdField ( ) ;
String functionIdentifierTransfer = TdEngineConstants . TDENGINE_KEY_TRANSFER_MAP . get ( mf . getFunctionIdentifier ( ) ) ;
String functionIdentifier = functionIdentifierTransfer = = null ? mf . getFunctionIdentifier ( ) : functionIdentifierTransfer ;
field . setFieldName ( functionIdentifier ) ;
schemaFieldValues . add ( field ) ;
} else if ( mf . getFunctionMode ( ) . equals ( HwDictConstants . FUNCTION_MODE_SERVICE ) ) {
modeFunctions . add ( mf ) ;
}
String tableName = TdEngineConstants . getDeviceDataTableName ( deviceId ) ;
TdSelectDto tdSelectDto = new TdSelectDto ( ) ;
tdSelectDto . setDatabaseName ( databaseName ) ;
tdSelectDto . setTableName ( tableName ) ;
} ) ;
tdSelectDto . setSchemaFieldValues ( schemaFieldValues ) ;
//从tdengine获取此设备的最新数据
List < Map < String , Object > > deviceLatestDataMapList =
( List < Map < String , Object > > ) this . remoteTdEngineService . getLatestData ( tdSelectDto , SecurityConstants . INNER ) . getData ( ) ;
List < TdField > schemaFieldValues = new ArrayList < > ( ) ;
List < HwDeviceModeFunction > modeFunctions = new ArrayList < > ( ) ;
for ( HwDeviceModeFunction mf : deviceModeFunctions ) {
if ( mf . getFunctionMode ( ) . equals ( HwDictConstants . FUNCTION_MODE_ATTRIBUTE )
& & ! mf . getDisplayFlag ( ) . equals ( HwDictConstants . DEVICE_MODE_FUNCTION_DISPLAY_FLAG_NO ) ) {
TdField field = new TdField ( ) ;
String functionIdentifierTransfer =
TdEngineConstants . TDENGINE_KEY_TRANSFER_MAP . get ( mf . getFunctionIdentifier ( ) ) ;
String functionIdentifier = functionIdentifierTransfer = = null ?
mf . getFunctionIdentifier ( ) : functionIdentifierTransfer ;
field . setFieldName ( functionIdentifier ) ;
schemaFieldValues . add ( field ) ;
} else if ( mf . getFunctionMode ( ) . equals ( HwDictConstants . FUNCTION_MODE_SERVICE ) ) {
modeFunctions . add ( mf ) ;
}
}
//获取此设备模型的功能列表
//获取可控制设备: 根据功能是属性的并且属性的数据类型是tinyint类型的( bool类型开关就是用tinyint) , 并且是读写的
// List<HwDeviceModeFunction> dds = deviceModeFunctions.stream()
// .filter(dmf -> dmf.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)
// && dmf.getDataType() != null
// && String.valueOf(dmf.getDataType())
// .equals(String.valueOf(DataTypeEnums.TINYINT.getDataCode()))
// && dmf.getRwFlag()!=null
// && dmf.getRwFlag().equals(HwDictConstants.RW_FLAG_RW)
// ).collect(Collectors.toList());
tdSelectDto . setSchemaFieldValues ( schemaFieldValues ) ;
List < Map < String , Object > > deviceLatestDataMapList =
( List < Map < String , Object > > ) this . remoteTdEngineService . getLatestData ( tdSelectDto , SecurityConstants . INNER ) . getData ( ) ;
//转换成map, key为标识符, value为功能名称( 主要tdengine存的是标识符, 用来下面转换成功能名称)
Map < String , String > functionIndentifierName = deviceModeFunctions . stream ( ) . collect (
Collectors . toMap ( HwDeviceModeFunction : : getFunctionIdentifier ,
HwDeviceModeFunction : : getFunctionName ) ) ;
Map < String , String > functionIndentifierNameMap = new HashMap < > ( ) ;
functionIndentifierName . 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 ) ;
// 创建标识符映射
Map < String , String > functionIndentifierNameMap = new HashMap < > ( ) ;
for ( HwDeviceModeFunction dmf : deviceModeFunctions ) {
String key = dmf . getFunctionIdentifier ( ) ;
String val = dmf . getFunctionName ( ) ;
String keyTransfer = TdEngineConstants . TDENGINE_KEY_TRANSFER_MAP . get ( key ) ;
functionIndentifierNameMap . put ( keyTransfer = = null ? key : keyTransfer , val ) ;
}
} ) ;
//获取可控制设备,根据是否有服务判断
// List<HwDeviceModeFunction> modeFunctions = deviceModeFunctions.stream()
// .filter(dmf -> dmf.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_SERVICE)
// ).collect(Collectors.toList());
// 处理控制设备
if ( modeFunctions ! = null & & ! modeFunctions . isEmpty ( ) ) {
for ( HwDeviceModeFunction modeFunction : modeFunctions ) {
HwDeviceVo hwDeviceVo = new HwDeviceVo ( ) ;
hwDeviceVo . setDeviceId ( deviceId ) ;
hwDeviceVo . setDeviceType ( HwDictConstants . CONTROL_DEVICE ) ;
hwDeviceVo . setDeviceCode ( hwDevice . getDeviceCode ( ) ) ;
hwDeviceVo . setDeviceName ( hwDevice . getDeviceName ( ) ) ;
hwDeviceVo . setDevicePic ( hwDevice . getDevicePic ( ) ) ;
hwDeviceVo . setDeviceModeFunction ( modeFunction ) ;
controlDeviceVos . add ( hwDeviceVo ) ;
}
}
if ( modeFunctions ! = null & & modeFunctions . size ( ) > 0 ) {
modeFunctions . forEach ( modeFunction - > {
// 处理采集数据
Map < String , Object > ddValueMap = new HashMap < > ( ) ;
Date updateTime = null ;
if ( deviceLatestDataMapList ! = null & & ! deviceLatestDataMapList . isEmpty ( ) ) {
for ( Map < String , Object > deviceLatestDataMap : deviceLatestDataMapList ) {
for ( Map . Entry < String , Object > entry : deviceLatestDataMap . entrySet ( ) ) {
String dataFunctionIdentifier = entry . getKey ( ) ;
// 处理时间戳字段
if ( "ts" . equals ( dataFunctionIdentifier ) & & entry . getValue ( ) ! = null ) {
try {
String ts = entry . getValue ( ) . toString ( ) ;
DateTimeFormatter dateTimeFormatter = DateTimeFormatter . ISO_OFFSET_DATE_TIME ;
ZonedDateTime parse = ZonedDateTime . parse ( ts , dateTimeFormatter ) ;
updateTime = Date . from ( parse . toInstant ( ) ) ;
} catch ( Exception e ) {
// log.error("解析时间戳出错: {}", entry.getValue(), e);
}
continue ; // 时间戳不添加到 ddValueMap
}
// 处理其他数据字段
if ( functionIndentifierNameMap . containsKey ( dataFunctionIdentifier ) ) {
String unit = "" ;
try {
// 修复:处理可能返回多个结果的情况
if ( "value1" . equals ( dataFunctionIdentifier ) ) {
unit = hwDevieModeFunctionMapper . selectUbitByIdAndName ( "value" , hwDevice . getDeviceModeId ( ) ) ;
} else {
unit = hwDevieModeFunctionMapper . selectUbitByIdAndName ( dataFunctionIdentifier , hwDevice . getDeviceModeId ( ) ) ;
}
// unit = (units != null && !units.isEmpty()) ? units.get(0) : null;
} catch ( Exception e ) {
System . out . println ( dataFunctionIdentifier + "---" + hwDevice . getDeviceModeId ( ) ) ;
// log.error("查询单位时出错: functionIdentifier={}, deviceModeId={}",
// dataFunctionIdentifier, hwDevice.getDeviceModeId(), e);
}
Object value = entry . getValue ( ) ;
if ( unit ! = null & & value ! = null ) {
value = value . toString ( ) + unit ;
}
ddValueMap . put ( functionIndentifierNameMap . get ( dataFunctionIdentifier ) , value ) ;
}
}
}
}
// 创建设备VO对象
HwDeviceVo hwDeviceVo = new HwDeviceVo ( ) ;
hwDeviceVo . setDeviceId ( deviceId ) ;
hwDeviceVo . setDeviceType ( HwDictConstants . CONTROL_DEVICE ) ;
hwDeviceVo . setDevice ModeId( hwDevice . getDeviceModeId ( ) ) ;
hwDeviceVo . setDeviceCode ( hwDevice . getDeviceCode ( ) ) ;
hwDeviceVo . setDeviceName ( hwDevice . getDeviceName ( ) ) ;
hwDeviceVo . setDevicePic ( hwDevice . getDevicePic ( ) ) ;
hwDeviceVo . setDeviceModeFunction ( modeFunction ) ;
controlDeviceVos . add ( hwDeviceVo ) ;
} ) ;
hwDeviceVo . setDeviceType ( HwDictConstants . ACQUISITION_DEVICE ) ;
hwDeviceVo . setDeviceDataMap ( ddValueMap ) ;
hwDeviceVo . setUpdateTime ( updateTime ) ; // 设置更新时间
acquisitionDeviceVos . add ( hwDeviceVo ) ;
}
}
//将functionIdetifier转换成功能名称
Map < String , Object > ddValueMap = new HashMap < String , Object > ( ) ;
if ( deviceLatestDataMapList ! = null ) {
deviceLatestDataMapList . forEach ( deviceLatestDataMap - > {
Set < String > functionIdentifiers = deviceLatestDataMap . keySet ( ) ;
for ( String dataFunctionIdentifier : functionIdentifiers ) {
if ( functionIndentifierNameMap . get ( dataFunctionIdentifier ) ! = null ) {
String unit ;
if ( dataFunctionIdentifier . equals ( "value1" ) ) {
unit = hwDevieModeFunctionMapper . selectUbitByIdAndName ( "value" , hwDevice . getDeviceModeId ( ) ) ;
} else {
unit = hwDevieModeFunctionMapper . selectUbitByIdAndName ( dataFunctionIdentifier , hwDevice . getDeviceModeId ( ) ) ;
}
Object value ;
if ( unit = = null ) {
value = deviceLatestDataMap . get ( dataFunctionIdentifier ) ;
} else {
value = deviceLatestDataMap . get ( dataFunctionIdentifier ) + unit ;
}
ddValueMap . put ( functionIndentifierNameMap . get ( dataFunctionIdentifier ) ,
value ) ;
}
}
} ) ;
}
//不论是否是控制型设备都显示最新数据
HwDeviceVo hwDeviceVo = new HwDeviceVo ( ) ;
hwDeviceVo . setDeviceId ( deviceId ) ;
hwDeviceVo . setDeviceModeId ( hwDevice . getDeviceModeId ( ) ) ;
hwDeviceVo . setDeviceCode ( hwDevice . getDeviceCode ( ) ) ;
hwDeviceVo . setDeviceName ( hwDevice . getDeviceName ( ) ) ;
hwDeviceVo . setDevicePic ( hwDevice . getDevicePic ( ) ) ;
hwDeviceVo . setDeviceType ( HwDictConstants . ACQUISITION_DEVICE ) ;
hwDeviceVo . setDeviceDataMap ( ddValueMap ) ;
if ( deviceLatestDataMapList . size ( ) > 0 ) {
String ts = deviceLatestDataMapList . get ( 0 ) . get ( "ts" ) . toString ( ) ;
DateTimeFormatter dateTime = DateTimeFormatter . ISO_OFFSET_DATE_TIME ;
ZonedDateTime parse = ZonedDateTime . parse ( ts , dateTime ) ;
Date updateTime = Date . from ( parse . toInstant ( ) ) ;
hwDeviceVo . setUpdateTime ( updateTime ) ;
}
acquisitionDeviceVos . add ( hwDeviceVo ) ;
devicesMap . put ( HwDictConstants . CONTROL_DEVICE_NAME , controlDeviceVos ) ;
devicesMap . put ( HwDictConstants . ACQUISITION_DEVICE_NAME , acquisitionDeviceVos ) ;
} ) ;
return devicesMap ;
} catch ( Exception e ) {
// 根据业务需求决定是否抛出异常或返回空结果
return Collections . emptyMap ( ) ;
}
devicesMap . put ( HwDictConstants . CONTROL_DEVICE_NAME , controlDeviceVos ) ;
devicesMap . put ( HwDictConstants . ACQUISITION_DEVICE_NAME , acquisitionDeviceVos ) ;
return devicesMap ;
}
// public Map<String, List<HwDeviceVo>> getDevicesByMonitor(HwDevice queryHwDevice) {
// try {
// Map<String, List<HwDeviceVo>> devicesMap = new HashMap<String, List<HwDeviceVo>>();
// List<HwDeviceVo> controlDeviceVos = new ArrayList<HwDeviceVo>();
// List<HwDeviceVo> acquisitionDeviceVos = new ArrayList<HwDeviceVo>();
// String databaseName = TdEngineConstants.getDatabaseName();
//
// List<HwDevice> hwDevices = hwDeviceMapper.selectHwDeviceListByMonitor(queryHwDevice);
//
// /* 获取该监控单元节点下的所有子孙节点的设备 */
// //获取所有监控单元
// List<HwMonitorUnit> hwMonitorUnits = hwMonitorUnitMapper.selectHwMonitorUnitList(new HwMonitorUnit());
// Long targetNodeId = queryHwDevice.getMonitorUnitId();//目标节点,即父节点ID
// //TODO( zangch, 2024.10.16) : 在hwDevices拼接子孙节点的设备列表, 数据库样本少未完全验证性能和有效性
// //调用递归方法
// List<HwMonitorUnit> descendants = getAllHwMonitorUnits(hwMonitorUnits, targetNodeId);
// // 遍历所有监控单元
// for (HwMonitorUnit hwMonitorUnit : descendants) {
// // 创建设备对象
// HwDevice hwMonitorUnitDevice = new HwDevice();
// // 设置监控单元ID
// hwMonitorUnitDevice.setMonitorUnitId(hwMonitorUnit.getMonitorUnitId());
// // 根据监控单元ID查询设备列表
// List<HwDevice> hwDevicesByMonitor = hwDeviceMapper.selectHwDeviceListByMonitor(hwMonitorUnitDevice);
// // 将查询到的设备列表添加到总列表中
// hwDevices.addAll(hwDevicesByMonitor);
// }
//
// if (hwDevices != null && !hwDevices.isEmpty()) {
// for(HwDevice hwDevice : hwDevices) {
// Long deviceId = hwDevice.getDeviceId();
// HwDeviceModeFunction queryDeviceModeFunction = new HwDeviceModeFunction();
// queryDeviceModeFunction.setDeviceModeId(hwDevice.getDeviceModeId());
// List<HwDeviceModeFunction> deviceModeFunctions = hwDevieModeFunctionMapper.selectHwDeviceModeFunctionList(queryDeviceModeFunction);
//
// String tableName = TdEngineConstants.getDeviceDataTableName(deviceId);
// TdSelectDto tdSelectDto = new TdSelectDto();
// tdSelectDto.setDatabaseName(databaseName);
// tdSelectDto.setTableName(tableName);
// List<TdField> schemaFieldValues = new ArrayList<TdField>();
// List<HwDeviceModeFunction> modeFunctions = new ArrayList<>();
//
// for (HwDeviceModeFunction mf : deviceModeFunctions) {
// //是属性的,并且是可显示的
// if (mf.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)
// && !mf.getDisplayFlag().equals(HwDictConstants.DEVICE_MODE_FUNCTION_DISPLAY_FLAG_NO)) {
// TdField field = new TdField();
// String functionIdentifierTransfer = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(mf.getFunctionIdentifier());
// String functionIdentifier = functionIdentifierTransfer == null ? mf.getFunctionIdentifier() : functionIdentifierTransfer;
// field.setFieldName(functionIdentifier);
// schemaFieldValues.add(field);
// } else if (mf.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_SERVICE)) {
// modeFunctions.add(mf);
// }
//
// }
// tdSelectDto.setSchemaFieldValues(schemaFieldValues);
// //从tdengine获取此设备的最新数据
// List<Map<String, Object>> deviceLatestDataMapList =
// (List<Map<String, Object>>) this.remoteTdEngineService.getLatestData(tdSelectDto, SecurityConstants.INNER).getData();
//
//
// //获取此设备模型的功能列表
// //获取可控制设备: 根据功能是属性的并且属性的数据类型是tinyint类型的( bool类型开关就是用tinyint) , 并且是读写的
//// List<HwDeviceModeFunction> dds = deviceModeFunctions.stream()
//// .filter(dmf -> dmf.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)
//// && dmf.getDataType() != null
//// && String.valueOf(dmf.getDataType())
//// .equals(String.valueOf(DataTypeEnums.TINYINT.getDataCode()))
//// && dmf.getRwFlag()!=null
//// && dmf.getRwFlag().equals(HwDictConstants.RW_FLAG_RW)
//// ).collect(Collectors.toList());
//
// //转换成map, key为标识符, value为功能名称( 主要tdengine存的是标识符, 用来下面转换成功能名称)
// Map<String, String> functionIndentifierName = deviceModeFunctions.stream().collect(
// Collectors.toMap(HwDeviceModeFunction::getFunctionIdentifier,
// HwDeviceModeFunction::getFunctionName));
// Map<String, String> functionIndentifierNameMap = new HashMap<>();
// functionIndentifierName.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);
//
// });
// //获取可控制设备,根据是否有服务判断
//// List<HwDeviceModeFunction> modeFunctions = deviceModeFunctions.stream()
//// .filter(dmf -> dmf.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_SERVICE)
//// ).collect(Collectors.toList());
//
// if (modeFunctions != null && modeFunctions.size() > 0) {
// for (HwDeviceModeFunction modeFunction : modeFunctions) {
// HwDeviceVo hwDeviceVo = new HwDeviceVo();
// hwDeviceVo.setDeviceId(deviceId);
// hwDeviceVo.setDeviceType(HwDictConstants.CONTROL_DEVICE);
// hwDeviceVo.setDeviceCode(hwDevice.getDeviceCode());
// hwDeviceVo.setDeviceName(hwDevice.getDeviceName());
// hwDeviceVo.setDevicePic(hwDevice.getDevicePic());
// hwDeviceVo.setDeviceModeFunction(modeFunction);
// controlDeviceVos.add(hwDeviceVo);
// }
// }
//
// //将functionIdetifier转换成功能名称
// Map<String, Object> ddValueMap = new HashMap<String, Object>();
// if (deviceLatestDataMapList != null) {
// for (Map<String, Object> deviceLatestDataMap : deviceLatestDataMapList) {
// Set<String> functionIdentifiers = deviceLatestDataMap.keySet();
// for (String dataFunctionIdentifier : functionIdentifiers) {
// if (functionIndentifierNameMap.get(dataFunctionIdentifier) != null) {
// String unit;
// if (dataFunctionIdentifier.equals("value1")) {
// unit = hwDevieModeFunctionMapper.selectUbitByIdAndName("value", hwDevice.getDeviceModeId());
// } else {
// unit = hwDevieModeFunctionMapper.selectUbitByIdAndName(dataFunctionIdentifier, hwDevice.getDeviceModeId());
// }
// Object value;
// if (unit == null) {
// value = deviceLatestDataMap.get(dataFunctionIdentifier);
// } else {
// value = deviceLatestDataMap.get(dataFunctionIdentifier) + unit;
// }
// ddValueMap.put(functionIndentifierNameMap.get(dataFunctionIdentifier),
// value);
// }
// }
// }
// }
// //不论是否是控制型设备都显示最新数据
// HwDeviceVo hwDeviceVo = new HwDeviceVo();
// hwDeviceVo.setDeviceId(deviceId);
// hwDeviceVo.setDeviceModeId(hwDevice.getDeviceModeId());
// hwDeviceVo.setDeviceCode(hwDevice.getDeviceCode());
// hwDeviceVo.setDeviceName(hwDevice.getDeviceName());
// hwDeviceVo.setDevicePic(hwDevice.getDevicePic());
// hwDeviceVo.setDeviceType(HwDictConstants.ACQUISITION_DEVICE);
// hwDeviceVo.setDeviceDataMap(ddValueMap);
// if (deviceLatestDataMapList.size() > 0) {
// String ts = deviceLatestDataMapList.get(0).get("ts").toString();
// DateTimeFormatter dateTime = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
// ZonedDateTime parse = ZonedDateTime.parse(ts, dateTime);
// Date updateTime = Date.from(parse.toInstant());
// hwDeviceVo.setUpdateTime(updateTime);
// }
// acquisitionDeviceVos.add(hwDeviceVo);
//
// }
// }
//
// devicesMap.put(HwDictConstants.CONTROL_DEVICE_NAME, controlDeviceVos);
// devicesMap.put(HwDictConstants.ACQUISITION_DEVICE_NAME, acquisitionDeviceVos);
//
// return devicesMap;
// }catch (Exception e){
// e.printStackTrace();
// System.out.println(e.getMessage());
// return null;
// }
// }
//TODO( zangch, 2024.10.16) :递归获取所有子孙节点,数据库数据太少没办法验证是否完全有效
/* 根据节点ID获取所有子孙节点*/
private List < HwMonitorUnit > getAllHwMonitorUnits ( List < HwMonitorUnit > hwMonitorUnits , Long nodeId ) {