fix measurement category

This commit is contained in:
baiYue 2026-06-12 11:16:06 +08:00
parent 5d49f07558
commit ed6c2ec041
7 changed files with 192 additions and 5 deletions

View File

@ -31,6 +31,7 @@ public:
virtual void clearData(){};
QJsonObject parseCTWindingDefaultValue(const QVariant &value); //QVariant类型到QJsonObject转换(数据库读取的是var是QString)
QList<MeasureAttributeType> getAttributeList(const QString& sMeta); //返回基模-bay属性组下所有属性
protected:
QMap<QString,PropertyContentInfo> _mapPro;
QFormLayout* createFormLayout(QWidget* parent);

View File

@ -1,4 +1,5 @@
#include "baseContentDlg.h"
#include "projectModelManager.h"
#include <QScrollArea>
#include <QFormLayout>
#include <QLabel>
@ -68,3 +69,8 @@ QJsonObject BaseContentDlg::parseCTWindingDefaultValue(const QVariant &value)
<< value.typeName();
return {};
}
QList<MeasureAttributeType> BaseContentDlg::getAttributeList(const QString& sMeta)
{
return ProjectModelManager::instance().getAttributeLabelInfo(sMeta);
}

View File

@ -71,7 +71,9 @@ void BayInfoDlg::setPropertyValue(QVariant var)
if(property)
{
_itemProperty = property;
QList<MeasureAttributeType> lstType = DataBase::GetInstance()->getMeasureAttributeTypes();
QString sMeta = property->metaModelName();
QList<MeasureAttributeType> lstType = getAttributeList(sMeta);
//QList<MeasureAttributeType> lstType = DataBase::GetInstance()->getMeasureAttributeTypes();
_validType = lstType;

View File

@ -411,7 +411,7 @@ void DiagramCavas::onSignal_panelDelete(const QString& name,int nType)
this->removeSubWindow(pPanel);
delete pPanel;
}
calculateLauncherVisible();
//calculateLauncherVisible();
emit clearTopology();
}

View File

@ -30,7 +30,8 @@ public:
QStringList getModelList() const; //获取元模型列表
QStringList getGroupList(const QString& model) const; //返回该元模下的属性组列表
QStringList getPublicGroupList() const; //返回公共属性组列表
QStringList getAttributeList(const QString& model,const QString& group) const; //根据元模名和组名返回属性列表
QStringList getAttributeList(const QString& model,const QString& group,bool bContainInvalid = false) const; //根据元模名和组名返回属性列表 bContainInvalid:包含不可用属性(visible = 2)
QList<MeasureAttributeType> getAttributeLabelInfo(const QString& model,const QString& group = "bay") const; //返回属性列表标签信息 元模名,属性组名
QStringList getPublicAttributeList(const QString& group); //返回公共属性组的属性列表
void setItemAttribute(const QString&,QStandardItem*); //设置item的属性(数据库表字段名)
QPair<QString,QString> combinePropertySql(const QStandardItem*); //根据item属性生成sql
@ -46,6 +47,7 @@ private:
QJsonObject getSelectedState(QList<QStandardItem*> select,QList<QStandardItem*> base); //返回json格式的选中状态
QString getItemDataType(const QStandardItem* pItem); //返回数据类型
ProjectModelSettingStruct getModelSetting(const QString& sMeta,const QString& sProject); //获取指定工程模的设定
QList<MeasureAttributeType> processSpecialAttribute(const QString&,const QString&) const; //处理特殊量测
QByteArray cleanHexData(const QByteArray& hexData);
QByteArray fixHexLength(const QByteArray& hexData);

View File

@ -19,6 +19,8 @@ BasePropertyManager::~BasePropertyManager()
{
qDeleteAll(m_entityData);
qDeleteAll(m_bayData);
m_entityData.clear();
m_bayData.clear();
}
void BasePropertyManager::insertEntityData(QUuid uid,BaseProperty* p)

View File

@ -394,7 +394,7 @@ QStringList ProjectModelManager::getPublicGroupList() const
return groupList;
}
QStringList ProjectModelManager::getAttributeList(const QString& sM,const QString& sG) const
QStringList ProjectModelManager::getAttributeList(const QString& sM,const QString& sG,bool bContainInvalid) const
{
QMap<int,modelType> modelType = DataBase::GetInstance()->ModelType();
QMap<int,attributeGroup> groupMap = DataBase::GetInstance()->AttributeGroup();
@ -426,7 +426,7 @@ QStringList ProjectModelManager::getAttributeList(const QString& sM,const QStrin
{
if(mt.modelTypeId == metaId && mt.attributeGroupId == groupId)
{
if(attMap[mt.attributeId].isVisible == 2) //2为特殊属性不加入选择
if(!bContainInvalid && attMap[mt.attributeId].isVisible == 2) //2为特殊属性不加入选择
continue;
lst.append(attMap[mt.attributeId].attribute);
}
@ -435,6 +435,58 @@ QStringList ProjectModelManager::getAttributeList(const QString& sM,const QStrin
return lst;
}
QList<MeasureAttributeType> ProjectModelManager::getAttributeLabelInfo(const QString& sM,const QString& sG) const
{
QMap<int,modelType> modelType = DataBase::GetInstance()->ModelType();
QMap<int,attributeGroup> groupMap = DataBase::GetInstance()->AttributeGroup();
QMap<int,modelAttribute> modelAttMap = DataBase::GetInstance()->ModelAttribute();
QMap<int,attribute> attMap = DataBase::GetInstance()->Attribute();
int metaId = -1;
int baseType = -1;
for(auto &meta:modelType)
{
if(sM == meta.modelType) //查找元模对应的id
{
metaId = meta.id;
baseType = meta.graphicElement;
break;
}
}
int groupId = -1;
for(auto &attGroup:groupMap)
{
if(attGroup.groupType == sG) //固定为bay
{
groupId = attGroup.id;
break;
}
}
QList<MeasureAttributeType> lst;
for(auto &mt:modelAttMap)
{
if(mt.modelTypeId == metaId && mt.attributeGroupId == groupId)
{
if(baseType == 4 || baseType == 5){ //pt和ct的情况,将visible为2的处理后加入量测列表
if(attMap[mt.attributeId].isVisible == 2){
auto tLst = processSpecialAttribute(attMap[mt.attributeId].attribute,attMap[mt.attributeId].attributeName);
lst += tLst;
}
}
else{ //其他元件直接添加到量测列表
MeasureAttributeType info;
info.tag = attMap[mt.attributeId].attribute;
info.name = attMap[mt.attributeId].attributeName;
lst.append(info);
}
}
}
return lst;
}
QStringList ProjectModelManager::getPublicAttributeList(const QString& group)
{
QMap<int,modelAttributePublic> modelAttPublic = DataBase::GetInstance()->ModelAttributePublic();
@ -861,6 +913,128 @@ ProjectModelSettingStruct ProjectModelManager::getModelSetting(const QString& sM
return setting;
}
QList<MeasureAttributeType> ProjectModelManager::processSpecialAttribute(const QString& attribute,const QString& attributeName) const
{
QList<MeasureAttributeType> lst;
QString attName = attribute;
QString attTag = attributeName;
const QChar firstChar = attName.isEmpty() ? QChar() : attName.at(0);
const bool hasDollar = attName.contains("$");
const bool hasUnderDollar = attName.contains("_$");
const bool hasSn = attName.contains("sn");
/* ========== 规则 1_$ ========== */
if (hasUnderDollar)
{
QStringList underDollarValues;
if (firstChar == 'I')
{
underDollarValues = QStringList{"a", "b", "c"};
}
else // U
{
underDollarValues = QStringList{"ab", "bc", "ca"}; // ✅ 已修正
}
if (hasSn)
{
for (const QString& u : underDollarValues)
{
QString tmpName = attName;
QString tmpTag = attTag;
tmpName.replace("_$", u);
tmpTag.replace("_$", u);
for (const QString& sn : {"s1","s2","s3"})
{
MeasureAttributeType m;
m.tag = tmpName;
m.name = tmpTag;
m.tag.replace("sn", sn);
m.name.replace("sn", sn);
lst.append(m);
}
}
}
else
{
for (const QString& u : underDollarValues)
{
MeasureAttributeType m;
m.tag = attName;
m.name = attTag;
m.tag.replace("_$", u);
m.name.replace("_$", u);
lst.append(m);
}
}
}
/* ========== 规则 2$ ========== */
else if (hasDollar)
{
QStringList dollarValues =
(firstChar == 'I') ? QStringList{"A","B","C"}
: QStringList{"AB","BC","CA"};
if (hasSn)
{
for (const QString& d : dollarValues)
{
QString tmpName = attName;
QString tmpTag = attTag;
tmpName.replace("$", d);
tmpTag.replace("$", d);
for (const QString& sn : {"s1","s2","s3"})
{
MeasureAttributeType m;
m.tag = tmpName;
m.name = tmpTag;
m.tag.replace("sn", sn);
m.name.replace("sn", sn);
lst.append(m);
}
}
}
else
{
for (const QString& d : dollarValues)
{
MeasureAttributeType m;
m.tag = attName;
m.name = attTag;
m.tag.replace("$", d);
m.name.replace("$", d);
lst.append(m);
}
}
}
/* ========== 规则 3仅 sn ========== */
else if (hasSn)
{
for (const QString& sn : {"s1","s2","s3"})
{
MeasureAttributeType m;
m.tag = attName;
m.name = attTag;
m.tag.replace("sn", sn);
m.name.replace("sn", sn);
lst.append(m);
}
}
/* ========== 规则 4无占位符 ========== */
else
{
MeasureAttributeType m;
m.tag = attName;
m.name = attTag;
lst.append(m);
}
return lst;
}
QByteArray ProjectModelManager::cleanHexData(const QByteArray& hexData) {
QByteArray cleaned = hexData;
// 移除空格、换行等空白字符