|
|
@ -163,7 +163,10 @@ class OutlineService { |
|
|
|
await _loadComponent(rootPath, dirNode.value, dirNode); |
|
|
|
await _loadComponent(rootPath, dirNode.value, dirNode); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'Business': |
|
|
|
case 'Business': |
|
|
|
// 其他操作类型的处理 |
|
|
|
await _loadBusiness(rootPath, dirNode.value, dirNode); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'Atom': |
|
|
|
|
|
|
|
await _loadAtom(rootPath, dirNode.value, dirNode); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
Logger().error("操作节点类型不支持: ${dirNode.value}"); |
|
|
|
Logger().error("操作节点类型不支持: ${dirNode.value}"); |
|
|
@ -222,6 +225,178 @@ class OutlineService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//加载原子逻辑层 |
|
|
|
|
|
|
|
static Future<void> _loadAtom(String rootPath, String? fieldName, OutlineNode parentNode) async { |
|
|
|
|
|
|
|
if (fieldName == null || fieldName.isEmpty) return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final uftatomDir = Directory('$rootPath\\uftatom'); |
|
|
|
|
|
|
|
if (!await uftatomDir.exists()) { |
|
|
|
|
|
|
|
Logger().error('uftatom目录不存在'); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 遍历所有.uftstructure文件 |
|
|
|
|
|
|
|
final uftatomFiles = |
|
|
|
|
|
|
|
await uftatomDir |
|
|
|
|
|
|
|
.list(recursive: true) |
|
|
|
|
|
|
|
.where( |
|
|
|
|
|
|
|
(entity) => |
|
|
|
|
|
|
|
entity.path.endsWith('.uftatomfunction') || |
|
|
|
|
|
|
|
entity.path.endsWith('.uftatomservice'), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.cast<File>() |
|
|
|
|
|
|
|
.toList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (final file in uftatomFiles) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
final content = await file.readAsString(); |
|
|
|
|
|
|
|
final document = XmlDocument.parse(content); |
|
|
|
|
|
|
|
String matchType = "I"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查找匹配的入参 |
|
|
|
|
|
|
|
final List<XmlElement> matchingProperties = |
|
|
|
|
|
|
|
document |
|
|
|
|
|
|
|
.findAllElements('inputParameters') |
|
|
|
|
|
|
|
.where((element) => element.getAttribute('id') == fieldName) |
|
|
|
|
|
|
|
.toList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (matchingProperties.isEmpty) { |
|
|
|
|
|
|
|
matchingProperties.addAll( |
|
|
|
|
|
|
|
document |
|
|
|
|
|
|
|
.findAllElements('outputParameters') |
|
|
|
|
|
|
|
.where((element) => element.getAttribute('id') == fieldName), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
matchType = "O"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (matchingProperties.isEmpty) { |
|
|
|
|
|
|
|
matchingProperties.addAll( |
|
|
|
|
|
|
|
document |
|
|
|
|
|
|
|
.findAllElements('internalParams') |
|
|
|
|
|
|
|
.where((element) => element.getAttribute('id') == fieldName), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
matchType = "X"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (matchingProperties.isNotEmpty) { |
|
|
|
|
|
|
|
// 获取structure:Structure节点的chineseName |
|
|
|
|
|
|
|
final businessNode = document.findAllElements('business:Function').firstOrNull; |
|
|
|
|
|
|
|
final chineseName = businessNode?.getAttribute('chineseName') ?? '未命名'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取文件名(不带路径) |
|
|
|
|
|
|
|
final fileName = file.path; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建并添加子节点 |
|
|
|
|
|
|
|
parentNode.children.add( |
|
|
|
|
|
|
|
OutlineNode( |
|
|
|
|
|
|
|
name: fileName, |
|
|
|
|
|
|
|
title: '$chineseName($matchType)', |
|
|
|
|
|
|
|
value: 'Atom', |
|
|
|
|
|
|
|
frequency: 0, |
|
|
|
|
|
|
|
isDirectory: false, // 这些是叶子节点 |
|
|
|
|
|
|
|
depth: 4, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
Logger().error('解析文件 ${file.path} 失败: $e'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger().info('为 $fieldName 找到 ${parentNode.children.length} 个匹配项'); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
Logger().error('加载UFT对象失败: $e'); |
|
|
|
|
|
|
|
rethrow; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//加载业务逻辑层 |
|
|
|
|
|
|
|
static Future<void> _loadBusiness( |
|
|
|
|
|
|
|
String rootPath, |
|
|
|
|
|
|
|
String? fieldName, |
|
|
|
|
|
|
|
OutlineNode parentNode, |
|
|
|
|
|
|
|
) async { |
|
|
|
|
|
|
|
if (fieldName == null || fieldName.isEmpty) return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final uftbusinessDir = Directory('$rootPath\\uftbusiness'); |
|
|
|
|
|
|
|
if (!await uftbusinessDir.exists()) { |
|
|
|
|
|
|
|
Logger().error('uftbusiness目录不存在'); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 遍历所有.uftstructure文件 |
|
|
|
|
|
|
|
final uftbusinessFiles = |
|
|
|
|
|
|
|
await uftbusinessDir |
|
|
|
|
|
|
|
.list(recursive: true) |
|
|
|
|
|
|
|
.where((entity) => entity.path.endsWith('.uftfunction')) |
|
|
|
|
|
|
|
.cast<File>() |
|
|
|
|
|
|
|
.toList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (final file in uftbusinessFiles) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
final content = await file.readAsString(); |
|
|
|
|
|
|
|
final document = XmlDocument.parse(content); |
|
|
|
|
|
|
|
String matchType = "I"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查找匹配的入参 |
|
|
|
|
|
|
|
final List<XmlElement> matchingProperties = |
|
|
|
|
|
|
|
document |
|
|
|
|
|
|
|
.findAllElements('inputParameters') |
|
|
|
|
|
|
|
.where((element) => element.getAttribute('id') == fieldName) |
|
|
|
|
|
|
|
.toList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (matchingProperties.isEmpty) { |
|
|
|
|
|
|
|
matchingProperties.addAll( |
|
|
|
|
|
|
|
document |
|
|
|
|
|
|
|
.findAllElements('outputParameters') |
|
|
|
|
|
|
|
.where((element) => element.getAttribute('id') == fieldName), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
matchType = "O"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (matchingProperties.isEmpty) { |
|
|
|
|
|
|
|
matchingProperties.addAll( |
|
|
|
|
|
|
|
document |
|
|
|
|
|
|
|
.findAllElements('internalParams') |
|
|
|
|
|
|
|
.where((element) => element.getAttribute('id') == fieldName), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
matchType = "X"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (matchingProperties.isNotEmpty) { |
|
|
|
|
|
|
|
// 获取structure:Structure节点的chineseName |
|
|
|
|
|
|
|
final businessNode = document.findAllElements('business:Function').firstOrNull; |
|
|
|
|
|
|
|
final chineseName = businessNode?.getAttribute('chineseName') ?? '未命名'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取文件名(不带路径) |
|
|
|
|
|
|
|
final fileName = file.path; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建并添加子节点 |
|
|
|
|
|
|
|
parentNode.children.add( |
|
|
|
|
|
|
|
OutlineNode( |
|
|
|
|
|
|
|
name: fileName, |
|
|
|
|
|
|
|
title: '$chineseName($matchType)', |
|
|
|
|
|
|
|
value: 'Business', |
|
|
|
|
|
|
|
frequency: 0, |
|
|
|
|
|
|
|
isDirectory: false, // 这些是叶子节点 |
|
|
|
|
|
|
|
depth: 4, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
Logger().error('解析文件 ${file.path} 失败: $e'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger().info('为 $fieldName 找到 ${parentNode.children.length} 个匹配项'); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
Logger().error('加载UFT对象失败: $e'); |
|
|
|
|
|
|
|
rethrow; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 私有方法:加载UFT对象 |
|
|
|
// 私有方法:加载UFT对象 |
|
|
|
static Future<void> _loadUftObject( |
|
|
|
static Future<void> _loadUftObject( |
|
|
|
String rootPath, |
|
|
|
String rootPath, |
|
|
|