修复UF20、UFT30接口数据更新数据缺失问题
This commit is contained in:
parent
b55596078d
commit
8ecf44db1a
|
|
@ -70,6 +70,8 @@ QString MetadataProcessor::readConfig(const QString& section, const QString& key
|
|||
|
||||
bool MetadataProcessor::writeJson(const QString& filePath, const QJsonObject& jsonObject)
|
||||
{
|
||||
LogManager::instance()->log(QString("准备写入JSON文件: %1, 对象大小: %2").arg(filePath).arg(jsonObject.size()));
|
||||
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
LogManager::instance()->logError(QString("无法打开文件: %1").arg(filePath));
|
||||
|
|
@ -77,11 +79,68 @@ bool MetadataProcessor::writeJson(const QString& filePath, const QJsonObject& js
|
|||
}
|
||||
|
||||
QJsonDocument doc(jsonObject);
|
||||
file.write(doc.toJson(QJsonDocument::Indented));
|
||||
qint64 bytesWritten = file.write(doc.toJson(QJsonDocument::Indented));
|
||||
file.close();
|
||||
|
||||
LogManager::instance()->log(QString("成功写入JSON文件: %1, 写入字节数: %2").arg(filePath).arg(bytesWritten));
|
||||
return true;
|
||||
}
|
||||
|
||||
QJsonObject MetadataProcessor::interfaceInfoToUFT3Json(const InterfaceInfo& info)
|
||||
{
|
||||
QJsonObject interfaceJson;
|
||||
interfaceJson["cname"] = info.cname;
|
||||
interfaceJson["eName"] = info.eName;
|
||||
interfaceJson["functionNo"] = info.functionNo;
|
||||
interfaceJson["flag"] = info.flag;
|
||||
interfaceJson["path"] = info.path;
|
||||
interfaceJson["code"] = info.code;
|
||||
interfaceJson["id"] = info.id;
|
||||
interfaceJson["sysStatus"] = info.sysStatus;
|
||||
interfaceJson["description"] = info.description;
|
||||
interfaceJson["moudle"] = info.moudle;
|
||||
|
||||
QJsonObject inputFieldsJson;
|
||||
for (const QString& fieldName : info.inputFields.keys()) {
|
||||
const FieldInfo& field = info.inputFields[fieldName];
|
||||
QJsonObject fieldJson;
|
||||
fieldJson["name"] = field.name;
|
||||
fieldJson["flag"] = field.flag;
|
||||
fieldJson["desc"] = field.desc;
|
||||
fieldJson["uuid"] = field.uuid;
|
||||
inputFieldsJson[fieldName] = fieldJson;
|
||||
}
|
||||
interfaceJson["inputFileds"] = inputFieldsJson;
|
||||
|
||||
QJsonObject outputFieldsJson;
|
||||
for (const QString& fieldName : info.outputFields.keys()) {
|
||||
const FieldInfo& field = info.outputFields[fieldName];
|
||||
QJsonObject fieldJson;
|
||||
fieldJson["name"] = field.name;
|
||||
fieldJson["flag"] = field.flag;
|
||||
fieldJson["desc"] = field.desc;
|
||||
fieldJson["paramType"] = field.paramType;
|
||||
fieldJson["uuid"] = field.uuid;
|
||||
outputFieldsJson[fieldName] = fieldJson;
|
||||
}
|
||||
interfaceJson["outputFileds"] = outputFieldsJson;
|
||||
|
||||
QJsonObject internalFieldsJson;
|
||||
for (const QString& fieldName : info.internalFields.keys()) {
|
||||
const FieldInfo& field = info.internalFields[fieldName];
|
||||
QJsonObject fieldJson;
|
||||
fieldJson["name"] = field.name;
|
||||
fieldJson["type"] = field.type;
|
||||
fieldJson["desc"] = field.desc;
|
||||
fieldJson["paramType"] = field.paramType;
|
||||
fieldJson["uuid"] = field.uuid;
|
||||
internalFieldsJson[fieldName] = fieldJson;
|
||||
}
|
||||
interfaceJson["internalFileds"] = internalFieldsJson;
|
||||
|
||||
return interfaceJson;
|
||||
}
|
||||
|
||||
QJsonObject MetadataProcessor::readJson(const QString& filePath)
|
||||
{
|
||||
QFile file(filePath);
|
||||
|
|
@ -204,7 +263,6 @@ bool MetadataProcessor::processUf2Interfaces(const QString& basePath)
|
|||
}
|
||||
|
||||
QString outputPath = QDir(uf2touft3Path).filePath("uf2.json");
|
||||
LogManager::instance()->log(QString("输出文件路径(uf2.json): %1").arg(outputPath));
|
||||
|
||||
if (!writeJson(outputPath, resultJson)) {
|
||||
return false;
|
||||
|
|
@ -213,7 +271,6 @@ bool MetadataProcessor::processUf2Interfaces(const QString& basePath)
|
|||
LogManager::instance()->log(QString("UF2.0 接口处理完成,结果已保存到: %1").arg(outputPath));
|
||||
if (!resultMap.isEmpty()) {
|
||||
QString firstKey = resultMap.keys().first();
|
||||
LogManager::instance()->log(QString("示例功能号: %1").arg(resultMap[firstKey].functionNo));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -247,65 +304,14 @@ bool MetadataProcessor::processUft3Interfaces(const QString& basePath)
|
|||
QMap<QString, InterfaceInfo> resultMap = result.first;
|
||||
QMap<QString, InterfaceInfo> transCodeMap = result.second;
|
||||
|
||||
|
||||
QJsonObject resultJson;
|
||||
for (const QString& key : resultMap.keys()) {
|
||||
const InterfaceInfo& info = resultMap[key];
|
||||
|
||||
QJsonObject interfaceJson;
|
||||
interfaceJson["cname"] = info.cname;
|
||||
interfaceJson["eName"] = info.eName;
|
||||
interfaceJson["functionNo"] = info.functionNo;
|
||||
interfaceJson["flag"] = info.flag;
|
||||
interfaceJson["path"] = info.path;
|
||||
interfaceJson["code"] = info.code;
|
||||
interfaceJson["id"] = info.id;
|
||||
interfaceJson["sysStatus"] = info.sysStatus;
|
||||
interfaceJson["description"] = info.description;
|
||||
interfaceJson["moudle"] = info.moudle;
|
||||
|
||||
QJsonObject inputFieldsJson;
|
||||
for (const QString& fieldName : info.inputFields.keys()) {
|
||||
const FieldInfo& field = info.inputFields[fieldName];
|
||||
QJsonObject fieldJson;
|
||||
fieldJson["name"] = field.name;
|
||||
fieldJson["flag"] = field.flag;
|
||||
fieldJson["desc"] = field.desc;
|
||||
fieldJson["uuid"] = field.uuid;
|
||||
inputFieldsJson[fieldName] = fieldJson;
|
||||
}
|
||||
interfaceJson["inputFileds"] = inputFieldsJson;
|
||||
|
||||
QJsonObject outputFieldsJson;
|
||||
for (const QString& fieldName : info.outputFields.keys()) {
|
||||
const FieldInfo& field = info.outputFields[fieldName];
|
||||
QJsonObject fieldJson;
|
||||
fieldJson["name"] = field.name;
|
||||
fieldJson["flag"] = field.flag;
|
||||
fieldJson["desc"] = field.desc;
|
||||
fieldJson["paramType"] = field.paramType;
|
||||
fieldJson["uuid"] = field.uuid;
|
||||
outputFieldsJson[fieldName] = fieldJson;
|
||||
}
|
||||
interfaceJson["outputFileds"] = outputFieldsJson;
|
||||
|
||||
QJsonObject internalFieldsJson;
|
||||
for (const QString& fieldName : info.internalFields.keys()) {
|
||||
const FieldInfo& field = info.internalFields[fieldName];
|
||||
QJsonObject fieldJson;
|
||||
fieldJson["name"] = field.name;
|
||||
fieldJson["type"] = field.type;
|
||||
fieldJson["desc"] = field.desc;
|
||||
fieldJson["paramType"] = field.paramType;
|
||||
fieldJson["uuid"] = field.uuid;
|
||||
internalFieldsJson[fieldName] = fieldJson;
|
||||
}
|
||||
interfaceJson["internalFileds"] = internalFieldsJson;
|
||||
|
||||
resultJson[key] = interfaceJson;
|
||||
resultJson[key] = interfaceInfoToUFT3Json(info);
|
||||
}
|
||||
|
||||
QString outputPath = QDir(uf2touft3Path).filePath("uft3.json");
|
||||
LogManager::instance()->log(QString("输出文件路径(uft3.json): %1").arg(outputPath));
|
||||
|
||||
if (!writeJson(outputPath, resultJson)) {
|
||||
return false;
|
||||
|
|
@ -314,26 +320,16 @@ bool MetadataProcessor::processUft3Interfaces(const QString& basePath)
|
|||
QJsonObject transCodeJson;
|
||||
for (const QString& key : transCodeMap.keys()) {
|
||||
const InterfaceInfo& info = transCodeMap[key];
|
||||
|
||||
QJsonObject interfaceJson;
|
||||
interfaceJson["cname"] = info.cname;
|
||||
interfaceJson["eName"] = info.eName;
|
||||
interfaceJson["functionNo"] = info.functionNo;
|
||||
interfaceJson["flag"] = info.flag;
|
||||
interfaceJson["path"] = info.path;
|
||||
interfaceJson["code"] = info.code;
|
||||
transCodeJson[key] = interfaceJson;
|
||||
transCodeJson[key] = interfaceInfoToUFT3Json(info);
|
||||
}
|
||||
|
||||
QString transOutputPath = QDir(uf2touft3Path).filePath("uft3Trans.json");
|
||||
LogManager::instance()->log(QString("输出文件路径(uft3Trans.json): %1").arg(transOutputPath));
|
||||
|
||||
if (!writeJson(transOutputPath, transCodeJson)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LogManager::instance()->log(QString("UFT3.0 接口处理完成,结果已保存到: %1").arg(outputPath));
|
||||
LogManager::instance()->log(QString("交易码结果已保存到: %1").arg(transOutputPath));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -26,6 +26,7 @@ private:
|
|||
QString readConfig(const QString& section, const QString& key, const QString& basePath);
|
||||
bool writeJson(const QString& filePath, const QJsonObject& jsonObject);
|
||||
QJsonObject readJson(const QString& filePath);
|
||||
QJsonObject interfaceInfoToUFT3Json(const InterfaceInfo& info);
|
||||
|
||||
QString m_basePath;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -93,19 +93,17 @@ InterfaceInfo Uf2Interface::loadInterface(const QString& filePath)
|
|||
field.desc = attrs.value("desc").toString();
|
||||
result.variableFields[field.name] = field;
|
||||
}
|
||||
else if (elementName == "code") {
|
||||
result.code = xml.readElementText();
|
||||
if (filePath.contains("不用编译")) {
|
||||
result.code.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (token == QXmlStreamReader::EndElement) {
|
||||
if (!elementStack.isEmpty()) {
|
||||
elementStack.pop();
|
||||
}
|
||||
|
||||
QString elementName = xml.name().toString();
|
||||
if (elementName == "code") {
|
||||
result.code = xml.text().toString();
|
||||
if (filePath.contains("不用编译")) {
|
||||
result.code.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,12 +160,17 @@ bool Uft3Interface::shouldFilter(const QString& filePath,
|
|||
QString fileName = fileInfo.fileName();
|
||||
QString relPath = filePath.mid(dirPath.length());
|
||||
|
||||
QString suffix = relPath.mid(relPath.indexOf('.'));
|
||||
if (!containNameList.contains(suffix)) {
|
||||
if (completeNameList.contains(fileName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (completeNameList.contains(fileName)) {
|
||||
int dotPos = relPath.indexOf('.');
|
||||
QString suffix;
|
||||
if (dotPos != -1) {
|
||||
suffix = relPath.mid(dotPos);
|
||||
}
|
||||
|
||||
if (!containNameList.contains(suffix)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue