修复转码模块缺失问题
This commit is contained in:
parent
4cb44fc2fa
commit
fad539e127
|
|
@ -123,10 +123,10 @@ QString Uf2Interface::getModuleEName(const QString& moduleXmlPath)
|
|||
QXmlStreamReader::TokenType token = xml.readNext();
|
||||
if (token == QXmlStreamReader::StartElement) {
|
||||
QString elementName = xml.name().toString();
|
||||
if (elementName == "basic") {
|
||||
if (elementName == "info") {
|
||||
QXmlStreamAttributes attrs = xml.attributes();
|
||||
if (attrs.hasAttribute("englishName")) {
|
||||
return attrs.value("englishName").toString();
|
||||
if (attrs.hasAttribute("ename")) {
|
||||
return attrs.value("ename").toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -144,18 +144,14 @@ bool Uf2Interface::shouldFilter(const QString& filePath,
|
|||
QString fileName = fileInfo.fileName();
|
||||
|
||||
if (completeNameList.contains(fileName)) {
|
||||
LogManager::instance()->log(QString("过滤文件(文件名匹配): %1").arg(filePath));
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const QString& name : containNameList) {
|
||||
if (filePath.contains(name, Qt::CaseInsensitive)) {
|
||||
LogManager::instance()->log(QString("过滤文件(路径包含): %1").arg(filePath));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
LogManager::instance()->log(QString("保留文件: %1").arg(filePath));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +167,8 @@ QMap<QString, InterfaceInfo> Uf2Interface::scanDir(const QString& dirPath,
|
|||
QMap<QString, QString> moduleCodeMap;
|
||||
moduleCodeMap["转融通"] = "ref";
|
||||
|
||||
auto scanModuleXml = [&](const QString& path) {
|
||||
std::function<void(const QString&)> scanModuleXmlRecursive;
|
||||
scanModuleXmlRecursive = [&](const QString& path) {
|
||||
if (path.isEmpty()) return;
|
||||
QDir dir(path);
|
||||
QStringList filters;
|
||||
|
|
@ -191,24 +188,14 @@ QMap<QString, InterfaceInfo> Uf2Interface::scanDir(const QString& dirPath,
|
|||
moduleCodeMap[modName] = modEName;
|
||||
}
|
||||
|
||||
QDir subDirs(path);
|
||||
QFileInfoList dirList = subDirs.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
QFileInfoList dirList = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (const QFileInfo& dirInfo : dirList) {
|
||||
QDir subDir(dirInfo.absoluteFilePath());
|
||||
QFileInfoList subFileList = subDir.entryInfoList(filters, QDir::Files);
|
||||
for (const QFileInfo& fileInfo : subFileList) {
|
||||
QString filePath = fileInfo.absoluteFilePath();
|
||||
filePath.replace('\\', '/');
|
||||
scanModuleXmlRecursive(dirInfo.absoluteFilePath());
|
||||
}
|
||||
};
|
||||
|
||||
if (filePath.contains("/数据库/")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QString modName = fileInfo.dir().dirName();
|
||||
QString modEName = getModuleEName(filePath);
|
||||
moduleCodeMap[modName] = modEName;
|
||||
}
|
||||
}
|
||||
auto scanModuleXml = [&](const QString& path) {
|
||||
scanModuleXmlRecursive(path);
|
||||
};
|
||||
|
||||
scanModuleXml(dirPath);
|
||||
|
|
@ -237,10 +224,18 @@ QMap<QString, InterfaceInfo> Uf2Interface::scanDir(const QString& dirPath,
|
|||
continue;
|
||||
}
|
||||
|
||||
QString modName = fileInfo.dir().dirName();
|
||||
QString sFilePath = filePath;
|
||||
int lastSlash = sFilePath.lastIndexOf('/');
|
||||
QString pathWithoutFile = sFilePath.left(lastSlash);
|
||||
int secondLastSlash = pathWithoutFile.lastIndexOf('/');
|
||||
QString pathWithoutLastDir = pathWithoutFile.left(secondLastSlash);
|
||||
int thirdLastSlash = pathWithoutLastDir.lastIndexOf('/');
|
||||
QString modName = pathWithoutLastDir.mid(thirdLastSlash + 1);
|
||||
|
||||
InterfaceInfo interfaceInfo = loadInterface(filePath);
|
||||
interfaceInfo.moudle = modName;
|
||||
interfaceInfo.moudleEName = moduleCodeMap.value(modName);
|
||||
QString moudleEName = moduleCodeMap.value(modName);
|
||||
interfaceInfo.moudleEName = moudleEName;
|
||||
interfaceInfo.serverType = serverType;
|
||||
|
||||
QString key = interfaceInfo.cname;
|
||||
|
|
|
|||
|
|
@ -61,12 +61,15 @@ void Uft3Table::parseTableFile(const QString& filePath, QMap<QString, QMap<QStri
|
|||
sFilePath.replace('\\', '/');
|
||||
|
||||
QFile file(sFilePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
LogManager::instance()->logError(QString("无法打开表结构文件: %1").arg(sFilePath));
|
||||
return;
|
||||
}
|
||||
|
||||
QXmlStreamReader xml(&file);
|
||||
QByteArray data = file.readAll();
|
||||
file.close();
|
||||
|
||||
QXmlStreamReader xml(data);
|
||||
|
||||
QString tableEngName = "";
|
||||
QString tablePath = "";
|
||||
|
|
@ -96,9 +99,15 @@ void Uft3Table::parseTableFile(const QString& filePath, QMap<QString, QMap<QStri
|
|||
QString elementName = xml.name().toString();
|
||||
QXmlStreamAttributes attrs = xml.attributes();
|
||||
|
||||
if (elementName == "uftstructure") {
|
||||
if (elementName == "Structure") {
|
||||
if (attrs.hasAttribute("chineseName")) {
|
||||
chineseName = attrs.value("chineseName").toString();
|
||||
}
|
||||
|
||||
if (attrs.hasAttribute("objectId")) {
|
||||
objectId = attrs.value("objectId").toString();
|
||||
}
|
||||
|
||||
if (attrs.hasAttribute("space")) {
|
||||
spaceName = attrs.value("space").toString();
|
||||
}
|
||||
|
|
@ -146,8 +155,6 @@ void Uft3Table::parseTableFile(const QString& filePath, QMap<QString, QMap<QStri
|
|||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
QString sUser = "";
|
||||
if (spaceName == "HS_UFT_DATA") {
|
||||
sUser = "hs_uft";
|
||||
|
|
|
|||
|
|
@ -117,7 +117,8 @@ void BatchConvertPage::initUI()
|
|||
layout->addWidget(progressBox);
|
||||
|
||||
QHBoxLayout *btnLayout = new QHBoxLayout;
|
||||
m_startBtn = new ElaPushButton("开始转换");
|
||||
m_startBtn = new QPushButton("开始转换");
|
||||
m_startBtn->setStyleSheet("background-color: #1abc9c; color: white; padding: 10px 30px; font-size: 14px; border: none; border-radius: 4px;");
|
||||
connect(m_startBtn, &QPushButton::clicked, this, &BatchConvertPage::onStartConvert);
|
||||
btnLayout->addStretch();
|
||||
btnLayout->addWidget(m_startBtn);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QStandardItemModel>
|
||||
#include <QPushButton>
|
||||
#include "ElaLineEdit.h"
|
||||
#include "ElaPushButton.h"
|
||||
#include "ElaTableView.h"
|
||||
#include "ElaProgressBar.h"
|
||||
#include "ElaText.h"
|
||||
|
|
@ -50,7 +50,7 @@ private:
|
|||
QStringList m_funcList;
|
||||
ElaProgressBar *m_progressBar;
|
||||
ElaText *m_progressLabel;
|
||||
ElaPushButton *m_startBtn;
|
||||
QPushButton *m_startBtn;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <QHeaderView>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardItem>
|
||||
#include <QLineEdit>
|
||||
#include "ElaComboBox.h"
|
||||
#include "ElaLineEdit.h"
|
||||
#include "ElaPushButton.h"
|
||||
|
|
@ -38,6 +39,7 @@ void UF20FunctionSearchPage::initUI()
|
|||
m_searchEdit = new ElaLineEdit;
|
||||
m_searchEdit->setPlaceholderText("输入查询内容");
|
||||
m_searchEdit->setMinimumWidth(300);
|
||||
connect(m_searchEdit, &QLineEdit::returnPressed, this, &UF20FunctionSearchPage::onSearch);
|
||||
searchLayout->addWidget(m_searchEdit);
|
||||
|
||||
ElaPushButton *searchBtn = new ElaPushButton("搜索");
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <QHeaderView>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardItem>
|
||||
#include <QLineEdit>
|
||||
#include "ElaComboBox.h"
|
||||
#include "ElaLineEdit.h"
|
||||
#include "ElaPushButton.h"
|
||||
|
|
@ -37,6 +38,7 @@ void UFT3FunctionSearchPage::initUI()
|
|||
m_searchEdit = new ElaLineEdit;
|
||||
m_searchEdit->setPlaceholderText("输入查询内容");
|
||||
m_searchEdit->setMinimumWidth(300);
|
||||
connect(m_searchEdit, &QLineEdit::returnPressed, this, &UFT3FunctionSearchPage::onSearch);
|
||||
searchLayout->addWidget(m_searchEdit);
|
||||
|
||||
ElaPushButton *searchBtn = new ElaPushButton("搜索");
|
||||
|
|
@ -48,7 +50,7 @@ void UFT3FunctionSearchPage::initUI()
|
|||
|
||||
m_tableModel = new QStandardItemModel(this);
|
||||
m_tableModel->setColumnCount(3);
|
||||
m_tableModel->setHorizontalHeaderLabels({"英文名", "功能编号", "功能名称"});
|
||||
m_tableModel->setHorizontalHeaderLabels({"功能名称", "英文名", "功能编号"});
|
||||
|
||||
m_resultTable = new ElaTableView;
|
||||
m_resultTable->setModel(m_tableModel);
|
||||
|
|
|
|||
|
|
@ -245,12 +245,14 @@ void MetadataUpdatePage::onUpdateUFT3()
|
|||
void MetadataUpdatePage::updateUf2Interfaces(const QStringList& items)
|
||||
{
|
||||
int itemCount = items.size();
|
||||
bool interfaceUpdated = false;
|
||||
|
||||
foreach (const QString& item, items) {
|
||||
_processLabel->setText(QString("正在更新UF20 - %1").arg(item));
|
||||
int currentIndex = items.indexOf(item);
|
||||
int progress = (itemCount == 1) ? 0 : (currentIndex * 100 / itemCount);
|
||||
_progressBar->setValue(progress);
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
if (item == "标准字段") {
|
||||
processUf2StdFields();
|
||||
|
|
@ -261,9 +263,14 @@ void MetadataUpdatePage::updateUf2Interfaces(const QStringList& items)
|
|||
} else if (item == "接口数据") {
|
||||
QString basePath = QCoreApplication::applicationDirPath();
|
||||
processUf2Interface(basePath);
|
||||
interfaceUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (interfaceUpdated) {
|
||||
_processLabel->setText("正在更新数据缓存...");
|
||||
QCoreApplication::processEvents();
|
||||
UF2ConfigReader::reloadUF20Config();
|
||||
}
|
||||
|
||||
_progressBar->setValue(100);
|
||||
|
|
@ -275,12 +282,14 @@ void MetadataUpdatePage::updateUf2Interfaces(const QStringList& items)
|
|||
void MetadataUpdatePage::updateUft3Interfaces(const QStringList& items)
|
||||
{
|
||||
int itemCount = items.size();
|
||||
bool interfaceUpdated = false;
|
||||
|
||||
foreach (const QString& item, items) {
|
||||
_processLabel->setText(QString("正在更新UFT30 - %1").arg(item));
|
||||
int currentIndex = items.indexOf(item);
|
||||
int progress = (itemCount == 1) ? 0 : (currentIndex * 100 / itemCount);
|
||||
_progressBar->setValue(progress);
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
if (item == "标准字段") {
|
||||
processUft3StdFields();
|
||||
|
|
@ -291,9 +300,14 @@ void MetadataUpdatePage::updateUft3Interfaces(const QStringList& items)
|
|||
} else if (item == "接口数据") {
|
||||
QString basePath = QCoreApplication::applicationDirPath();
|
||||
processUft3Interface(basePath);
|
||||
interfaceUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (interfaceUpdated) {
|
||||
_processLabel->setText("正在更新数据缓存...");
|
||||
QCoreApplication::processEvents();
|
||||
UFT3ConfigReader::reloadUFT3Config();
|
||||
}
|
||||
|
||||
_progressBar->setValue(100);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#include "ElaProgressBar.h"
|
||||
#include "ElaCheckBox.h"
|
||||
#include "metadataupdate/metadataprocessor.h"
|
||||
#include "utils/uf2configreader.h"
|
||||
#include "utils/uft3configreader.h"
|
||||
#include <QGridLayout>
|
||||
#include <QMessageBox>
|
||||
#include <QThread>
|
||||
|
|
|
|||
|
|
@ -105,8 +105,9 @@ bool DataCache::initDatabase()
|
|||
return false;
|
||||
}
|
||||
|
||||
m_db.exec("PRAGMA synchronous = OFF");
|
||||
m_db.exec("PRAGMA journal_mode = MEMORY");
|
||||
QSqlQuery query(m_db);
|
||||
query.exec("PRAGMA synchronous = OFF");
|
||||
query.exec("PRAGMA journal_mode = MEMORY");
|
||||
|
||||
LogManager::instance()->log("数据缓存 - 数据库打开成功");
|
||||
return createTables();
|
||||
|
|
@ -122,16 +123,12 @@ void DataCache::setDataLoaded(bool loaded)
|
|||
m_dataLoaded = loaded;
|
||||
}
|
||||
|
||||
bool DataCache::saveUF20Config(const QString& fileName, const QJsonObject& data)
|
||||
bool DataCache::saveUF20Config(const QJsonObject& data)
|
||||
{
|
||||
if (!m_db.isOpen()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fileName != "uf2.json") {
|
||||
return true;
|
||||
}
|
||||
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
|
||||
|
|
@ -178,16 +175,12 @@ bool DataCache::saveUF20Config(const QString& fileName, const QJsonObject& data)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool DataCache::saveUFT3Config(const QString& fileName, const QJsonObject& data)
|
||||
bool DataCache::saveUFT3Config(const QJsonObject& data)
|
||||
{
|
||||
if (!m_db.isOpen()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fileName != "uft3.json") {
|
||||
return true;
|
||||
}
|
||||
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ public:
|
|||
bool isDataLoaded() const;
|
||||
void setDataLoaded(bool loaded);
|
||||
|
||||
bool saveUF20Config(const QString& fileName, const QJsonObject& data);
|
||||
bool saveUFT3Config(const QString& fileName, const QJsonObject& data);
|
||||
bool saveUF20Config(const QJsonObject& data);
|
||||
bool saveUFT3Config(const QJsonObject& data);
|
||||
|
||||
bool hasUF20Config(const QString& fileName);
|
||||
bool hasUFT3Config(const QString& fileName);
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ bool UF2ConfigReader::loadAllUF20Config()
|
|||
}
|
||||
|
||||
QJsonObject config = doc.object();
|
||||
if (!DataCache::instance()->saveUF20Config("uf2.json", config)) {
|
||||
LogManager::instance()->logError("UF20配置加载失败 - 保存失败: uf2.json");
|
||||
if (!DataCache::instance()->saveUF20Config(config)) {
|
||||
LogManager::instance()->logError("UF20配置加载失败 - 保存失败");
|
||||
m_failedFiles.append("uf2.json");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ bool UF2ConfigReader::reloadUF20Config()
|
|||
}
|
||||
|
||||
QJsonObject config = doc.object();
|
||||
if (!DataCache::instance()->saveUF20Config("uf2.json", config)) {
|
||||
if (!DataCache::instance()->saveUF20Config(config)) {
|
||||
LogManager::instance()->logError("UF20配置重新加载失败 - 保存失败: uf2.json");
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public:
|
|||
explicit UF2ConfigReader(QObject *parent = nullptr);
|
||||
|
||||
bool loadAllUF20Config();
|
||||
bool reloadUF20Config();
|
||||
static bool reloadUF20Config();
|
||||
|
||||
bool isUF20Loaded() const;
|
||||
QStringList getFailedFiles() const;
|
||||
|
|
@ -26,7 +26,7 @@ public:
|
|||
private:
|
||||
static bool loadCnameCache();
|
||||
|
||||
QString getBinPath();
|
||||
static QString getBinPath();
|
||||
|
||||
QStringList m_failedFiles;
|
||||
bool m_loaded;
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ bool UFT3ConfigReader::loadAllUFT3Config()
|
|||
}
|
||||
|
||||
QJsonObject config = doc.object();
|
||||
if (!DataCache::instance()->saveUFT3Config("uft3.json", config)) {
|
||||
LogManager::instance()->logError("UFT3配置加载失败 - 保存失败: uft3.json");
|
||||
if (!DataCache::instance()->saveUFT3Config(config)) {
|
||||
LogManager::instance()->logError("UFT3配置加载失败 - 保存失败");
|
||||
m_failedFiles.append("uft3.json");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -75,26 +75,45 @@ QStringList UFT3ConfigReader::getFailedFiles() const
|
|||
bool UFT3ConfigReader::reloadUFT3Config()
|
||||
{
|
||||
QString binPath = getBinPath();
|
||||
QString filePath = binPath + "/uft3.json";
|
||||
QString filePath1 = binPath + "/uft3.json";
|
||||
QString filePath2 = binPath + "/uft3Trans.json";
|
||||
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
LogManager::instance()->logError(QString("UFT3配置重新加载失败 - 无法打开文件: %1").arg(filePath));
|
||||
QJsonObject mergedConfig;
|
||||
|
||||
QFile file1(filePath1);
|
||||
if (file1.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QByteArray data1 = file1.readAll();
|
||||
QJsonDocument doc1 = QJsonDocument::fromJson(data1);
|
||||
if (!doc1.isNull() && doc1.isObject()) {
|
||||
mergedConfig = doc1.object();
|
||||
}
|
||||
file1.close();
|
||||
} else {
|
||||
LogManager::instance()->logWarning(QString("UFT3配置重新加载 - 无法打开文件: %1").arg(filePath1));
|
||||
}
|
||||
|
||||
QFile file2(filePath2);
|
||||
if (file2.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QByteArray data2 = file2.readAll();
|
||||
QJsonDocument doc2 = QJsonDocument::fromJson(data2);
|
||||
if (!doc2.isNull() && doc2.isObject()) {
|
||||
QJsonObject transConfig = doc2.object();
|
||||
for (auto it = transConfig.begin(); it != transConfig.end(); ++it) {
|
||||
mergedConfig[it.key()] = it.value();
|
||||
}
|
||||
}
|
||||
file2.close();
|
||||
} else {
|
||||
LogManager::instance()->logWarning(QString("UFT3配置重新加载 - 无法打开文件: %1").arg(filePath2));
|
||||
}
|
||||
|
||||
if (mergedConfig.isEmpty()) {
|
||||
LogManager::instance()->logError("UFT3配置重新加载失败 - 两个JSON文件都无效");
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray data = file.readAll();
|
||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
||||
file.close();
|
||||
|
||||
if (doc.isNull() || !doc.isObject()) {
|
||||
LogManager::instance()->logError(QString("UFT3配置重新加载失败 - JSON解析失败: %1").arg(filePath));
|
||||
return false;
|
||||
}
|
||||
|
||||
QJsonObject config = doc.object();
|
||||
if (!DataCache::instance()->saveUFT3Config("uft3.json", config)) {
|
||||
LogManager::instance()->logError("UFT3配置重新加载失败 - 保存失败: uft3.json");
|
||||
if (!DataCache::instance()->saveUFT3Config(mergedConfig)) {
|
||||
LogManager::instance()->logError("UFT3配置重新加载失败 - 保存失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public:
|
|||
explicit UFT3ConfigReader(QObject *parent = nullptr);
|
||||
|
||||
bool loadAllUFT3Config();
|
||||
bool reloadUFT3Config();
|
||||
static bool reloadUFT3Config();
|
||||
|
||||
bool isUFT3Loaded() const;
|
||||
QStringList getFailedFiles() const;
|
||||
|
|
@ -26,7 +26,7 @@ public:
|
|||
private:
|
||||
static bool loadCnameCache();
|
||||
|
||||
QString getBinPath();
|
||||
static QString getBinPath();
|
||||
|
||||
QStringList m_failedFiles;
|
||||
bool m_loaded;
|
||||
|
|
|
|||
Loading…
Reference in New Issue