finish bay/measure save/load
This commit is contained in:
parent
38c8bc51e3
commit
93892cc597
|
|
@ -31,8 +31,12 @@ class BayProperty:public AbstractProperty //间隔属性(待扩展)
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
BayProperty(QObject* parent)
|
BayProperty(QObject* parent = nullptr)
|
||||||
:AbstractProperty(parent){
|
:AbstractProperty(parent){
|
||||||
|
dVoltage = 0.0;
|
||||||
|
dFla = 0.0; //电流
|
||||||
|
dCapacity = 0.0; //容量
|
||||||
|
sType = "normal";
|
||||||
}
|
}
|
||||||
virtual ~BayProperty(){};
|
virtual ~BayProperty(){};
|
||||||
public:
|
public:
|
||||||
|
|
@ -185,9 +189,9 @@ class VariableProperty:public BaseProperty //收到的变量数据
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VariableProperty(QObject* parent);
|
VariableProperty(QObject* parent = nullptr);
|
||||||
~VariableProperty();
|
~VariableProperty();
|
||||||
|
|
||||||
modelDataInfo getPropertyValue() const;
|
modelDataInfo& getPropertyValue() const;
|
||||||
};
|
};
|
||||||
#endif // DATABASE_H
|
#endif // DATABASE_H
|
||||||
|
|
|
||||||
|
|
@ -292,6 +292,8 @@ struct propertyStateInfo //属性
|
||||||
QString type; //属性类型
|
QString type; //属性类型
|
||||||
QVariant defaultValue; //默认值
|
QVariant defaultValue; //默认值
|
||||||
int lengthPrecision = 999; //长度限制
|
int lengthPrecision = 999; //长度限制
|
||||||
|
int isVisibe = 1; //是否可见(0:不可见,1:可见,2:特殊项)
|
||||||
|
bool lock = false; //值手动改变时置true,下次保存时恢复
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(propertyStateInfo);
|
Q_DECLARE_METATYPE(propertyStateInfo);
|
||||||
|
|
@ -568,6 +570,8 @@ struct MeasurementInfo //量测
|
||||||
QString channel; //设备端子
|
QString channel; //设备端子
|
||||||
QString type; //量测类型
|
QString type; //量测类型
|
||||||
int size; //量测size
|
int size; //量测size
|
||||||
|
QUuid bayUuid; //所属间隔
|
||||||
|
QUuid componentUuid; //所属设备
|
||||||
};
|
};
|
||||||
|
|
||||||
//==================================================
|
//==================================================
|
||||||
|
|
@ -586,7 +590,6 @@ struct baseComponentInfo //基模图元数据
|
||||||
|
|
||||||
struct componentInfo //工程模图元数据
|
struct componentInfo //工程模图元数据
|
||||||
{
|
{
|
||||||
int id = 0;
|
|
||||||
QUuid uuid;
|
QUuid uuid;
|
||||||
QString modelName;
|
QString modelName;
|
||||||
QString nspath;
|
QString nspath;
|
||||||
|
|
@ -659,6 +662,33 @@ struct stationInfo
|
||||||
bool is_local = true;
|
bool is_local = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct bayInfo
|
||||||
|
{
|
||||||
|
QUuid uuid;
|
||||||
|
QString name;
|
||||||
|
QString type;
|
||||||
|
double unom;
|
||||||
|
double fla;
|
||||||
|
double capacity;
|
||||||
|
QString description;
|
||||||
|
bool inService;
|
||||||
|
int nState;
|
||||||
|
QString grid;
|
||||||
|
QString zone;
|
||||||
|
QString station;
|
||||||
|
QJsonObject business;
|
||||||
|
QJsonObject fromUuid;
|
||||||
|
QJsonObject toUuid;
|
||||||
|
QJsonObject protect;
|
||||||
|
QJsonObject faultRec;
|
||||||
|
QJsonObject status;
|
||||||
|
QJsonObject dynSense;
|
||||||
|
QJsonObject instruct;
|
||||||
|
QJsonObject etc;
|
||||||
|
QList<QUuid> components;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*struct busStability
|
/*struct busStability
|
||||||
{
|
{
|
||||||
int componentId = 0;
|
int componentId = 0;
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ BaseProperty::BaseProperty(QObject* parent)
|
||||||
|
|
||||||
BaseProperty::~BaseProperty()
|
BaseProperty::~BaseProperty()
|
||||||
{
|
{
|
||||||
|
qDebug()<<"release by "<<uuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************属性变量*************************/
|
/*************************属性变量*************************/
|
||||||
|
|
@ -68,8 +68,7 @@ VariableProperty::~VariableProperty()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
modelDataInfo VariableProperty::getPropertyValue() const
|
modelDataInfo& VariableProperty::getPropertyValue() const
|
||||||
{
|
{
|
||||||
ModelDataMap mapData = DataManager::instance().modelData();
|
return DataManager::instance().modelData()[sModelName];
|
||||||
return mapData[sModelName];
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ namespace Ui { class bayInfoDlg; }
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class MeasureSettingDlg;
|
class MeasureSettingDlg;
|
||||||
|
class BayProperty;
|
||||||
|
|
||||||
class BayInfoDlg : public BaseContentDlg
|
class BayInfoDlg : public BaseContentDlg
|
||||||
{
|
{
|
||||||
|
|
@ -26,6 +27,7 @@ public:
|
||||||
void setUi();
|
void setUi();
|
||||||
void addMeasure(MeasurementInfo);
|
void addMeasure(MeasurementInfo);
|
||||||
void addOtherMeasure(QStringList); //本间隔的其他量测
|
void addOtherMeasure(QStringList); //本间隔的其他量测
|
||||||
|
BaseProperty* getProperty() {return _itemProperty;}
|
||||||
public slots:
|
public slots:
|
||||||
void onAddClicked();
|
void onAddClicked();
|
||||||
void onDeleteClicked();
|
void onDeleteClicked();
|
||||||
|
|
@ -34,6 +36,8 @@ private:
|
||||||
void initial();
|
void initial();
|
||||||
private:
|
private:
|
||||||
Ui::bayInfoDlg *ui;
|
Ui::bayInfoDlg *ui;
|
||||||
|
BayProperty* _bayProperty; //当前间隔属性
|
||||||
|
BaseProperty* _itemProperty; //当前对象属性
|
||||||
MeasureSettingDlg* _measureDlg;
|
MeasureSettingDlg* _measureDlg;
|
||||||
QList<measureAttributeType> _validType; //可用的属性列表
|
QList<measureAttributeType> _validType; //可用的属性列表
|
||||||
QMap<QString,MeasurementInfo> _mapMeasure; //量测列表
|
QMap<QString,MeasurementInfo> _mapMeasure; //量测列表
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ namespace Ui { class bayManagerContentDlg; }
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class BayProperty;
|
class BayProperty;
|
||||||
|
class QButtonGroup;
|
||||||
|
|
||||||
class BayManagerContentDlg : public QDialog
|
class BayManagerContentDlg : public QDialog
|
||||||
{
|
{
|
||||||
|
|
@ -26,6 +27,7 @@ public:
|
||||||
private:
|
private:
|
||||||
Ui::bayManagerContentDlg *ui;
|
Ui::bayManagerContentDlg *ui;
|
||||||
BayProperty* _pData;
|
BayProperty* _pData;
|
||||||
|
QButtonGroup* _stateGroup;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public:
|
||||||
QVector<ModelProperty*> allConnectionProperty();
|
QVector<ModelProperty*> allConnectionProperty();
|
||||||
QMap<QUuid,GraphicsProjectModelItem*>& allItems();
|
QMap<QUuid,GraphicsProjectModelItem*>& allItems();
|
||||||
bool addNodeItem(QUuid uuid,GraphicsProjectModelItem*);
|
bool addNodeItem(QUuid uuid,GraphicsProjectModelItem*);
|
||||||
void addNodeItem(QUuid id,/*int type,*/QPointF pos);
|
void addNodeItem(QUuid id,QPointF pos);
|
||||||
GraphicsProjectModelItem* nodeItem(QUuid uuid);
|
GraphicsProjectModelItem* nodeItem(QUuid uuid);
|
||||||
QVariant nodeData(QUuid nodeId, NodeRole role) const;
|
QVariant nodeData(QUuid nodeId, NodeRole role) const;
|
||||||
BaseProperty* addNodeData(QUuid id,int type,QString name,QString modelName); //对应component数据,一个data可对应多个item(id,类型,名称,工程模名)
|
BaseProperty* addNodeData(QUuid id,int type,QString name,QString modelName); //对应component数据,一个data可对应多个item(id,类型,名称,工程模名)
|
||||||
|
|
@ -79,6 +79,7 @@ public:
|
||||||
void generateProjectModel(const QString&,QList<GraphicsBaseModelItem*>,QList<GraphicsNonStandardItem*>); //由基模生成工程模
|
void generateProjectModel(const QString&,QList<GraphicsBaseModelItem*>,QList<GraphicsNonStandardItem*>); //由基模生成工程模
|
||||||
void addProjectItemByBaseData(DrawingPanel*,GraphicsBaseModelItem*,BaseProperty*); //从基模item生成工程模item
|
void addProjectItemByBaseData(DrawingPanel*,GraphicsBaseModelItem*,BaseProperty*); //从基模item生成工程模item
|
||||||
/*************************间隔*****************************/
|
/*************************间隔*****************************/
|
||||||
|
void addBayItem(QUuid);
|
||||||
bool addBayItem(QUuid,ElectricBayItem*);
|
bool addBayItem(QUuid,ElectricBayItem*);
|
||||||
void addItemsToBay(QList<GraphicsBaseItem*>,ElectricBayItem*); //将对象添加到间隔
|
void addItemsToBay(QList<GraphicsBaseItem*>,ElectricBayItem*); //将对象添加到间隔
|
||||||
BayProperty* addBayData(QUuid uuid);
|
BayProperty* addBayData(QUuid uuid);
|
||||||
|
|
@ -90,6 +91,8 @@ public:
|
||||||
void addBayByData(BayProperty*); //基模bay生成工程模bay
|
void addBayByData(BayProperty*); //基模bay生成工程模bay
|
||||||
|
|
||||||
void addTestData(); //生成测试基模
|
void addTestData(); //生成测试基模
|
||||||
|
QJsonObject turnListToJson(QList<QUuid> lst,QString sInerTag,QString sOutTag); //将list转换为QJsonObject,<lst,内部标签,外部标签>
|
||||||
|
QList<QUuid> turnJsonArrToList(QJsonObject obj,QString sInner,QString sOut);
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void activatePage(const QString&); //激活当前model所在page
|
void activatePage(const QString&); //激活当前model所在page
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
QVBoxLayout* _layout;
|
QVBoxLayout* _layout;
|
||||||
QWidget* createEditor(propertyStateInfo); //创建属性
|
QWidget* createEditor(propertyStateInfo); //创建属性
|
||||||
|
private:
|
||||||
|
QMap<QString,propertyStateInfo> _curValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ BaseInfoDlg::BaseInfoDlg(QWidget *parent)
|
||||||
_stateGroup = new QButtonGroup(this);
|
_stateGroup = new QButtonGroup(this);
|
||||||
_stateGroup->addButton(ui->rb_inService,1);
|
_stateGroup->addButton(ui->rb_inService,1);
|
||||||
_stateGroup->addButton(ui->rb_outService,0);
|
_stateGroup->addButton(ui->rb_outService,0);
|
||||||
|
_stateGroup->setExclusive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseInfoDlg::~BaseInfoDlg()
|
BaseInfoDlg::~BaseInfoDlg()
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ BayInfoDlg::BayInfoDlg(QWidget *parent)
|
||||||
: BaseContentDlg(parent)
|
: BaseContentDlg(parent)
|
||||||
, ui(new Ui::bayInfoDlg)
|
, ui(new Ui::bayInfoDlg)
|
||||||
,_measureDlg(nullptr)
|
,_measureDlg(nullptr)
|
||||||
|
,_bayProperty(nullptr)
|
||||||
|
,_itemProperty(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||||
|
|
@ -48,6 +50,7 @@ QMap<QString,propertyStateInfo> BayInfoDlg::getPropertyValue(BaseProperty* pPro)
|
||||||
{
|
{
|
||||||
QMap<QString,propertyStateInfo> map;
|
QMap<QString,propertyStateInfo> map;
|
||||||
|
|
||||||
|
pPro->setDataChanged(true);
|
||||||
pPro->setMeasurement(_mapMeasure);
|
pPro->setMeasurement(_mapMeasure);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +58,7 @@ QMap<QString,propertyStateInfo> BayInfoDlg::getPropertyValue(BaseProperty* pPro)
|
||||||
void BayInfoDlg::setPropertyValue(QVariant var)
|
void BayInfoDlg::setPropertyValue(QVariant var)
|
||||||
{
|
{
|
||||||
_mapMeasure.clear();
|
_mapMeasure.clear();
|
||||||
ui->tableWidget_other->setRowCount(0);;
|
ui->tableWidget_other->setRowCount(0);
|
||||||
ui->tableWidget_local->setRowCount(0); //清空列表
|
ui->tableWidget_local->setRowCount(0); //清空列表
|
||||||
ui->le_zhbh->clear();
|
ui->le_zhbh->clear();
|
||||||
ui->le_jk->clear();
|
ui->le_jk->clear();
|
||||||
|
|
@ -67,6 +70,7 @@ void BayInfoDlg::setPropertyValue(QVariant var)
|
||||||
BaseProperty* property = static_cast<BaseProperty*>(var.value<void*>());
|
BaseProperty* property = static_cast<BaseProperty*>(var.value<void*>());
|
||||||
if(property)
|
if(property)
|
||||||
{
|
{
|
||||||
|
_itemProperty = property;
|
||||||
QList<measureAttributeType> lstType = DataBase::GetInstance()->getMeasureAttributeTypes();
|
QList<measureAttributeType> lstType = DataBase::GetInstance()->getMeasureAttributeTypes();
|
||||||
auto map = property->getMeasurement();
|
auto map = property->getMeasurement();
|
||||||
|
|
||||||
|
|
@ -77,7 +81,7 @@ void BayInfoDlg::setPropertyValue(QVariant var)
|
||||||
}
|
}
|
||||||
|
|
||||||
//间隔处理
|
//间隔处理
|
||||||
BayProperty* pBay = nullptr;
|
_bayProperty = nullptr;
|
||||||
QMap<QUuid,ElectricBayItem*> mapBay = _curModelController->allBayItem();
|
QMap<QUuid,ElectricBayItem*> mapBay = _curModelController->allBayItem();
|
||||||
for(auto& item:mapBay){
|
for(auto& item:mapBay){
|
||||||
AbstractProperty* pPro = item->getProperty();
|
AbstractProperty* pPro = item->getProperty();
|
||||||
|
|
@ -86,22 +90,22 @@ void BayInfoDlg::setPropertyValue(QVariant var)
|
||||||
QList<QUuid> lstCompo = pBayPro->getLstComponent(); //获取间隔下的component,找到本component对应的间隔
|
QList<QUuid> lstCompo = pBayPro->getLstComponent(); //获取间隔下的component,找到本component对应的间隔
|
||||||
for(auto& id:lstCompo){
|
for(auto& id:lstCompo){
|
||||||
if(id == property->uuid()){
|
if(id == property->uuid()){
|
||||||
pBay = pBayPro;
|
_bayProperty = pBayPro;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pBay){
|
if(_bayProperty){
|
||||||
auto lstFrom = pBay->getLstFrom();
|
auto lstFrom = _bayProperty->getLstFrom();
|
||||||
auto lstTo = pBay->getLstTo();
|
auto lstTo = _bayProperty->getLstTo();
|
||||||
auto lstProtect = pBay->getLstProtect();
|
auto lstProtect = _bayProperty->getLstProtect();
|
||||||
auto lstFaultRecord = pBay->getLstFaultRecord();
|
auto lstFaultRecord = _bayProperty->getLstFaultRecord();
|
||||||
auto lstDynSense = pBay->getLstDynSense();
|
auto lstDynSense = _bayProperty->getLstDynSense();
|
||||||
auto lstStatus = pBay->getLstStatus();
|
auto lstStatus = _bayProperty->getLstStatus();
|
||||||
auto lstInstruct = pBay->getLstInstruct();
|
auto lstInstruct = _bayProperty->getLstInstruct();
|
||||||
auto lstEtc = pBay->getLstEtc();
|
auto lstEtc = _bayProperty->getLstEtc();
|
||||||
|
|
||||||
QStringList sLstFrom;
|
QStringList sLstFrom;
|
||||||
for(auto& fromId:lstFrom){
|
for(auto& fromId:lstFrom){
|
||||||
|
|
@ -168,7 +172,7 @@ void BayInfoDlg::setPropertyValue(QVariant var)
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<BaseProperty*> lstOther;
|
QList<BaseProperty*> lstOther;
|
||||||
QList<QUuid> lstCompo = pBay->getLstComponent();
|
QList<QUuid> lstCompo = _bayProperty->getLstComponent();
|
||||||
for(auto& compoId:lstCompo){
|
for(auto& compoId:lstCompo){
|
||||||
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(compoId);
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(compoId);
|
||||||
if(pPro){
|
if(pPro){
|
||||||
|
|
@ -196,7 +200,7 @@ void BayInfoDlg::setPropertyValue(QVariant var)
|
||||||
ui->le_ztjc->setText(sLstStatus.join("、"));
|
ui->le_ztjc->setText(sLstStatus.join("、"));
|
||||||
ui->le_qt->setText(sLstEtc.join("、"));
|
ui->le_qt->setText(sLstEtc.join("、"));
|
||||||
|
|
||||||
ui->le_bayName->setText(pBay->tag());
|
ui->le_bayName->setText(_bayProperty->name());
|
||||||
addOtherMeasure(lstOtherMeasure);
|
addOtherMeasure(lstOtherMeasure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -263,7 +267,14 @@ void BayInfoDlg::addMeasure(MeasurementInfo info)
|
||||||
QTableWidgetItem* sizeItem = new QTableWidgetItem(QString::number(info.size));
|
QTableWidgetItem* sizeItem = new QTableWidgetItem(QString::number(info.size));
|
||||||
ui->tableWidget_local->setItem(row, 5, sizeItem);
|
ui->tableWidget_local->setItem(row, 5, sizeItem);
|
||||||
|
|
||||||
_mapMeasure.insert(info.name,info);
|
if(_bayProperty && _itemProperty){
|
||||||
|
QUuid bayId = _bayProperty->uuid();
|
||||||
|
QUuid itemId = _itemProperty->uuid();
|
||||||
|
info.bayUuid = bayId;
|
||||||
|
info.componentUuid = itemId;
|
||||||
|
_mapMeasure.insert(info.name,info);
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0;i < _validType.size();++i){
|
for(int i = 0;i < _validType.size();++i){
|
||||||
if(_validType.at(i).name == info.name){ //可用类型中移除该类型
|
if(_validType.at(i).name == info.name){ //可用类型中移除该类型
|
||||||
_validType.removeAt(i);
|
_validType.removeAt(i);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <QButtonGroup>
|
||||||
#include "bayManagerContentDlg.h"
|
#include "bayManagerContentDlg.h"
|
||||||
#include "baseProperty.h"
|
#include "baseProperty.h"
|
||||||
#include "ui_bayManagerContentDlg.h"
|
#include "ui_bayManagerContentDlg.h"
|
||||||
|
|
@ -20,6 +21,11 @@ BayManagerContentDlg::~BayManagerContentDlg()
|
||||||
|
|
||||||
void BayManagerContentDlg::initial()
|
void BayManagerContentDlg::initial()
|
||||||
{
|
{
|
||||||
|
_stateGroup = new QButtonGroup(this);
|
||||||
|
_stateGroup->addButton(ui->rbtn_in,1);
|
||||||
|
_stateGroup->addButton(ui->rbtn_out,0);
|
||||||
|
_stateGroup->setExclusive(true);
|
||||||
|
|
||||||
QStringList headerText;
|
QStringList headerText;
|
||||||
headerText<<"选择"<<"名称";
|
headerText<<"选择"<<"名称";
|
||||||
ui->tw_zongHe->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->tw_zongHe->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
@ -68,7 +74,7 @@ void BayManagerContentDlg::initial()
|
||||||
void BayManagerContentDlg::updateByProperty()
|
void BayManagerContentDlg::updateByProperty()
|
||||||
{
|
{
|
||||||
if(_pData){
|
if(_pData){
|
||||||
ui->le_name->setText(_pData->tag());
|
ui->le_name->setText(_pData->name());
|
||||||
ui->tw_zongHe->setRowCount(0);
|
ui->tw_zongHe->setRowCount(0);
|
||||||
ui->tw_jianKong->setRowCount(0);
|
ui->tw_jianKong->setRowCount(0);
|
||||||
ui->tw_dongTai->setRowCount(0);
|
ui->tw_dongTai->setRowCount(0);
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ void BayManagerDlg::generatePage(QList<BayProperty*> lstBay)
|
||||||
pBay->updateByProperty();
|
pBay->updateByProperty();
|
||||||
int index = ui->stackedWidget->addWidget(pBay);
|
int index = ui->stackedWidget->addWidget(pBay);
|
||||||
_contentData.insert(index,pBay);
|
_contentData.insert(index,pBay);
|
||||||
QListWidgetItem* pItem = new QListWidgetItem(pData->tag());
|
QListWidgetItem* pItem = new QListWidgetItem(pData->name());
|
||||||
pItem->setData(Qt::UserRole+1,index);
|
pItem->setData(Qt::UserRole+1,index);
|
||||||
ui->listWidget->addItem(pItem);
|
ui->listWidget->addItem(pItem);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include "topologyManager.h"
|
#include "topologyManager.h"
|
||||||
#include "projectDiagramNameInput.h"
|
#include "projectDiagramNameInput.h"
|
||||||
#include "baseProperty.h"
|
#include "baseProperty.h"
|
||||||
|
#include "graphicsItem/electricBayItem.h"
|
||||||
|
|
||||||
DrawingPanel::DrawingPanel(PowerEntity* pEntity,QWidget *parent,DiagramMode mode)
|
DrawingPanel::DrawingPanel(PowerEntity* pEntity,QWidget *parent,DiagramMode mode)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
|
@ -207,6 +208,20 @@ QJsonObject DrawingPanel::getDiagramInfo() const
|
||||||
arrConnect.append(connect);
|
arrConnect.append(connect);
|
||||||
}
|
}
|
||||||
obj["connections"] = arrConnect;
|
obj["connections"] = arrConnect;
|
||||||
|
|
||||||
|
QJsonArray arrBay;
|
||||||
|
QMap<QUuid,ElectricBayItem*> mapBay = _pModel->allBayItem();
|
||||||
|
for(auto& bayItem:mapBay){
|
||||||
|
AbstractProperty* pPro = bayItem->getProperty();
|
||||||
|
BayProperty* pBay = dynamic_cast<BayProperty*>(pPro);
|
||||||
|
if(pBay)
|
||||||
|
{
|
||||||
|
QJsonObject bay;
|
||||||
|
bay["id"] = pBay->uuid().toString();
|
||||||
|
arrBay.append(bay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
obj["bays"] = arrBay;
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
@ -256,6 +271,17 @@ void DrawingPanel::loadNodes(QJsonObject obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonArray bayArr = obj["bays"].toArray();
|
||||||
|
for(QJsonValueRef bayJson:bayArr)
|
||||||
|
{
|
||||||
|
QJsonObject bay = bayJson.toObject();
|
||||||
|
QUuid id = QUuid(bay["id"].toString());
|
||||||
|
if(_pModel)
|
||||||
|
{
|
||||||
|
_pModel->addBayItem(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(_mode == DM_run)
|
if(_mode == DM_run)
|
||||||
{
|
{
|
||||||
if(_pModel)
|
if(_pModel)
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos)
|
||||||
QMap<QUuid,BaseProperty*> mapData = BasePropertyManager::instance().getEntityData(); //加载的图形必定关联component(todo:完善判断条件,如判断拓扑节点)
|
QMap<QUuid,BaseProperty*> mapData = BasePropertyManager::instance().getEntityData(); //加载的图形必定关联component(todo:完善判断条件,如判断拓扑节点)
|
||||||
if(mapData.contains(id))
|
if(mapData.contains(id))
|
||||||
{
|
{
|
||||||
pro = mapData[id];
|
pro = mapData.value(id);
|
||||||
if(pro)
|
if(pro)
|
||||||
{
|
{
|
||||||
int type = pro->graphicsType();
|
int type = pro->graphicsType();
|
||||||
|
|
@ -209,7 +209,7 @@ BaseProperty* FixedPortsModel::addNodeData(QUuid id,int type,QString name,QStrin
|
||||||
if(pData != nullptr)
|
if(pData != nullptr)
|
||||||
return pData;
|
return pData;
|
||||||
|
|
||||||
VariableProperty* item = new VariableProperty(this);
|
VariableProperty* item = new VariableProperty();
|
||||||
//todo:关联到对应data
|
//todo:关联到对应data
|
||||||
|
|
||||||
if(item)
|
if(item)
|
||||||
|
|
@ -256,6 +256,14 @@ void FixedPortsModel::loadNodeDataFromDataBase()
|
||||||
if(pEntity){
|
if(pEntity){
|
||||||
createTopoTerminalsByData(pEntity,info.context);
|
createTopoTerminalsByData(pEntity,info.context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<MeasurementInfo> lstMeasure = DataBase::GetInstance()->getMeasurement(info.uuid); //添加设备量测
|
||||||
|
QMap<QString,MeasurementInfo> mapMeasure;
|
||||||
|
for(auto& info:lstMeasure)
|
||||||
|
{
|
||||||
|
mapMeasure.insert(info.name,info);
|
||||||
|
}
|
||||||
|
pData->setMeasurement(mapMeasure);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<topologicInfo> lstTopo = DataBase::GetInstance()->getAllTopologics();
|
QList<topologicInfo> lstTopo = DataBase::GetInstance()->getAllTopologics();
|
||||||
|
|
@ -266,6 +274,35 @@ void FixedPortsModel::loadNodeDataFromDataBase()
|
||||||
|
|
||||||
TopologyManager::instance().createConnection(QString::number(info.id),from_pin,to_pin,info.uuid_from.toString(),info.uuid_to.toString());
|
TopologyManager::instance().createConnection(QString::number(info.id),from_pin,to_pin,info.uuid_from.toString(),info.uuid_to.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<bayInfo> lstBay = DataBase::GetInstance()->getAllBay();
|
||||||
|
for(auto& bay:lstBay)
|
||||||
|
{
|
||||||
|
BayProperty* pBay = addBayData(bay.uuid);
|
||||||
|
pBay->setName(bay.name);
|
||||||
|
pBay->setType(bay.type);
|
||||||
|
pBay->setLstComponent(bay.components);
|
||||||
|
pBay->setVoltage(bay.unom);
|
||||||
|
pBay->setFla(bay.fla);
|
||||||
|
pBay->setCapacity(bay.capacity);
|
||||||
|
pBay->setInService(bay.inService);
|
||||||
|
auto fromLst = turnJsonArrToList(bay.fromUuid,"id","ids");
|
||||||
|
pBay->setLstFrom(fromLst);
|
||||||
|
auto toLst = turnJsonArrToList(bay.toUuid,"id","ids");
|
||||||
|
pBay->setLstTo(toLst);
|
||||||
|
auto proptecLst = turnJsonArrToList(bay.protect,"id","ids");
|
||||||
|
pBay->setLstProtect(proptecLst);
|
||||||
|
auto falRecLst = turnJsonArrToList(bay.faultRec,"id","ids");
|
||||||
|
pBay->setLstFaultRecord(falRecLst);
|
||||||
|
auto dynSenLst = turnJsonArrToList(bay.dynSense,"id","ids");
|
||||||
|
pBay->setLstDynSense(dynSenLst);
|
||||||
|
auto staLst = turnJsonArrToList(bay.status,"id","ids");
|
||||||
|
pBay->setLstStatus(staLst);
|
||||||
|
auto insLst = turnJsonArrToList(bay.instruct,"id","ids");
|
||||||
|
pBay->setLstInstruct(insLst);
|
||||||
|
auto etcLst = turnJsonArrToList(bay.etc,"id","ids");
|
||||||
|
pBay->setLstEtc(etcLst);
|
||||||
|
}
|
||||||
_dataInitialised = true;
|
_dataInitialised = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -462,6 +499,39 @@ QVariant FixedPortsModel::nodeData(QUuid nodeId, NodeRole role) const
|
||||||
|
|
||||||
void FixedPortsModel::saveNode(int nPageId)
|
void FixedPortsModel::saveNode(int nPageId)
|
||||||
{
|
{
|
||||||
|
for(auto& bay:_bayItem)
|
||||||
|
{
|
||||||
|
AbstractProperty* pro = bay->getProperty(); //间隔
|
||||||
|
BayProperty* pBay = dynamic_cast<BayProperty*>(pro);
|
||||||
|
if(pBay){
|
||||||
|
bool val = DataBase::GetInstance()->ifBayExist(pBay->uuid());
|
||||||
|
if(!val){
|
||||||
|
QJsonObject objFrom = turnListToJson(pBay->getLstFrom(),"id","ids");
|
||||||
|
QJsonObject objTo= turnListToJson(pBay->getLstTo(),"id","ids");
|
||||||
|
QJsonObject objProtec= turnListToJson(pBay->getLstProtect(),"id","ids");
|
||||||
|
QJsonObject objFalRec= turnListToJson(pBay->getLstFaultRecord(),"id","ids");
|
||||||
|
QJsonObject objStatus= turnListToJson(pBay->getLstStatus(),"id","ids");
|
||||||
|
QJsonObject objDynSen= turnListToJson(pBay->getLstDynSense(),"id","ids");
|
||||||
|
QJsonObject objIns= turnListToJson(pBay->getLstInstruct(),"id","ids");
|
||||||
|
QJsonObject objEtc= turnListToJson(pBay->getLstEtc(),"id","ids");
|
||||||
|
|
||||||
|
DataBase::GetInstance()->insertBay(pBay->uuid(),pBay->name(),pBay->getType(),pBay->getVoltage(),pBay->getFla(),pBay->getCapacity(),"1",pBay->getInService(),0,"1","1","1",QJsonObject(),objFrom,objTo,objProtec,objFalRec,objStatus,objDynSen,objIns,objEtc,pBay->getLstComponent());
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
QJsonObject objFrom = turnListToJson(pBay->getLstFrom(),"id","ids");
|
||||||
|
QJsonObject objTo= turnListToJson(pBay->getLstTo(),"id","ids");
|
||||||
|
QJsonObject objProtec= turnListToJson(pBay->getLstProtect(),"id","ids");
|
||||||
|
QJsonObject objFalRec= turnListToJson(pBay->getLstFaultRecord(),"id","ids");
|
||||||
|
QJsonObject objStatus= turnListToJson(pBay->getLstStatus(),"id","ids");
|
||||||
|
QJsonObject objDynSen= turnListToJson(pBay->getLstDynSense(),"id","ids");
|
||||||
|
QJsonObject objIns= turnListToJson(pBay->getLstInstruct(),"id","ids");
|
||||||
|
QJsonObject objEtc= turnListToJson(pBay->getLstEtc(),"id","ids");
|
||||||
|
|
||||||
|
DataBase::GetInstance()->updateBay(pBay->uuid(),pBay->name(),pBay->getVoltage(),pBay->getFla(),pBay->getCapacity(),"",pBay->getInService(),0,QJsonObject(),objFrom,objTo,objProtec,objFalRec,objStatus,objDynSen,objIns,objEtc,pBay->getLstComponent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QMap<QUuid,GraphicsProjectModelItem*> mapItems = allItems();
|
QMap<QUuid,GraphicsProjectModelItem*> mapItems = allItems();
|
||||||
for(auto& pItem:mapItems)
|
for(auto& pItem:mapItems)
|
||||||
{
|
{
|
||||||
|
|
@ -487,11 +557,12 @@ void FixedPortsModel::saveNode(int nPageId)
|
||||||
}
|
}
|
||||||
if(pData->dataChanged())
|
if(pData->dataChanged())
|
||||||
{
|
{
|
||||||
|
pData->setDataChanged(false);
|
||||||
bool exist = DataBase::GetInstance()->componentExist(pData->uuid().toString());
|
bool exist = DataBase::GetInstance()->componentExist(pData->uuid().toString());
|
||||||
VariableProperty* pVariable = dynamic_cast<VariableProperty*>(pData);
|
VariableProperty* pVariable = dynamic_cast<VariableProperty*>(pData);
|
||||||
if(pVariable)
|
if(pVariable)
|
||||||
{
|
{
|
||||||
modelDataInfo dataInfo = pVariable->getPropertyValue();
|
modelDataInfo& dataInfo = pVariable->getPropertyValue();
|
||||||
if(exist) //已存在更新
|
if(exist) //已存在更新
|
||||||
{
|
{
|
||||||
DataBase::GetInstance()->updateComponent(pData->uuid(),pData->tag(),pData->name(),pData->context());
|
DataBase::GetInstance()->updateComponent(pData->uuid(),pData->tag(),pData->name(),pData->context());
|
||||||
|
|
@ -500,6 +571,13 @@ void FixedPortsModel::saveNode(int nPageId)
|
||||||
if(val.groupName == "component")
|
if(val.groupName == "component")
|
||||||
continue;
|
continue;
|
||||||
DataBase::GetInstance()->updateDynamicProperty(pData->uuid(),val);
|
DataBase::GetInstance()->updateDynamicProperty(pData->uuid(),val);
|
||||||
|
if(val.mapInfo.contains(pData->uuid())){ //保存时将数据锁复原
|
||||||
|
auto& mapPro = val.mapInfo[pData->uuid()];
|
||||||
|
for(auto& pro:mapPro)
|
||||||
|
{
|
||||||
|
pro.lock = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -510,20 +588,74 @@ void FixedPortsModel::saveNode(int nPageId)
|
||||||
if(val.groupName == "component")
|
if(val.groupName == "component")
|
||||||
continue;
|
continue;
|
||||||
DataBase::GetInstance()->insertDynamicProperty(pData->uuid(),val);
|
DataBase::GetInstance()->insertDynamicProperty(pData->uuid(),val);
|
||||||
|
if(val.mapInfo.contains(pData->uuid())){ //保存时将数据锁复原
|
||||||
|
auto& mapPro = val.mapInfo[pData->uuid()];
|
||||||
|
for(auto& pro:mapPro)
|
||||||
|
{
|
||||||
|
pro.lock = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMap<QString,MeasurementInfo> mapMeasure = pData->getMeasurement(); //量测
|
||||||
|
|
||||||
|
QList<MeasurementInfo> lstDataBase = DataBase::GetInstance()->getMeasurement(pData->uuid()); //数据库中现有量测
|
||||||
|
for(auto& info:mapMeasure)
|
||||||
|
{
|
||||||
|
int tpe = 0; //todo:建立类型映射表
|
||||||
|
if(info.type == "遥测"){
|
||||||
|
tpe = 0;
|
||||||
|
}
|
||||||
|
else if(info.type == "遥信"){
|
||||||
|
tpe = 1;
|
||||||
|
}
|
||||||
|
else if(info.type == "遥控"){
|
||||||
|
tpe = 2;
|
||||||
|
}
|
||||||
|
else if(info.type == "遥调"){
|
||||||
|
tpe = 3;
|
||||||
|
}
|
||||||
|
else if(info.type == "整定值"){
|
||||||
|
tpe = 4;
|
||||||
|
}
|
||||||
|
QJsonObject obj;
|
||||||
|
obj["type"] = info.equipment;
|
||||||
|
obj["main_pos"] = info.channel;
|
||||||
|
bool val = DataBase::GetInstance()->ifMeasureExist(info.name,pData->uuid());
|
||||||
|
if(val){
|
||||||
|
DataBase::GetInstance()->updateMeasurement(info.name,tpe,obj,info.size,pData->uuid());
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
DataBase::GetInstance()->insertMeasurement(info.name,info.tag,tpe,obj,info.size,info.bayUuid,info.componentUuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0;i < lstDataBase.size();++i) //从数据库记录中移除操作过的对象
|
||||||
|
{
|
||||||
|
if(lstDataBase[i].name == info.name){
|
||||||
|
lstDataBase.removeAt(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto& info:lstDataBase) //操作的记录小于数据库中的记录,删除库中多出的记录
|
||||||
|
{
|
||||||
|
DataBase::GetInstance()->delteMeasurement(info.name,info.componentUuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pData->type() == 8){
|
if(pData->type() == 8){
|
||||||
PowerConnection* pCon = TopologyManager::instance().connection(fromPin,toPin);
|
PowerConnection* pCon = TopologyManager::instance().connection(fromPin,toPin);
|
||||||
if(pCon){
|
if(pCon){
|
||||||
DataBase::GetInstance()->insertTopologic(con.nSrcNodeId,con.nDestNodeId,context,0,"",0);
|
int id = DataBase::GetInstance()->topologicExist(con.nSrcNodeId,con.nDestNodeId);
|
||||||
|
if(id == -1)
|
||||||
|
DataBase::GetInstance()->insertTopologic(con.nSrcNodeId,con.nDestNodeId,context,0,"",0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//todo:savebay
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedPortsModel::onSignal_ifExits(QUuid id,const QString& str,int type,GraphicsProjectModelItem* pitem)
|
void FixedPortsModel::onSignal_ifExits(QUuid id,const QString& str,int type,GraphicsProjectModelItem* pitem)
|
||||||
|
|
@ -1246,6 +1378,19 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FixedPortsModel::addBayItem(QUuid id)
|
||||||
|
{
|
||||||
|
QMap<QUuid,BayProperty*> mapData = BasePropertyManager::instance().getBayData(); //加载的图形必定关联component(todo:完善判断条件,如判断拓扑节点)
|
||||||
|
if(mapData.contains(id))
|
||||||
|
{
|
||||||
|
BayProperty* pro = mapData.value(id);
|
||||||
|
if(pro)
|
||||||
|
{
|
||||||
|
addBayByData(pro);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool FixedPortsModel::addBayItem(QUuid id,ElectricBayItem* pBay)
|
bool FixedPortsModel::addBayItem(QUuid id,ElectricBayItem* pBay)
|
||||||
{
|
{
|
||||||
if(_bayItem.contains(id))
|
if(_bayItem.contains(id))
|
||||||
|
|
@ -1281,7 +1426,7 @@ BayProperty* FixedPortsModel::addBayData(QUuid uuid)
|
||||||
if(pData != nullptr)
|
if(pData != nullptr)
|
||||||
return pData;
|
return pData;
|
||||||
|
|
||||||
BayProperty* item = new BayProperty(this);
|
BayProperty* item = new BayProperty();
|
||||||
|
|
||||||
if(item)
|
if(item)
|
||||||
{
|
{
|
||||||
|
|
@ -1394,7 +1539,7 @@ void FixedPortsModel::addBayByData(BayProperty* pData)
|
||||||
auto pBay = new ElectricBayItem(rec);
|
auto pBay = new ElectricBayItem(rec);
|
||||||
pBay->setItemType(GIT_bay);
|
pBay->setItemType(GIT_bay);
|
||||||
pBay->setProperty(pData);
|
pBay->setProperty(pData);
|
||||||
pBay->setText(pData->tag());
|
pBay->setText(pData->name());
|
||||||
addBayItem(pData->uuid(),pBay);
|
addBayItem(pData->uuid(),pBay);
|
||||||
getScene()->addItem(pBay);
|
getScene()->addItem(pBay);
|
||||||
}
|
}
|
||||||
|
|
@ -1477,3 +1622,34 @@ void FixedPortsModel::addTestData()
|
||||||
addItemsToBay(lst,pBay);
|
addItemsToBay(lst,pBay);
|
||||||
_scene->addItem(pBay);
|
_scene->addItem(pBay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonObject FixedPortsModel::turnListToJson(QList<QUuid> lst,QString sInerTag,QString sOutTag)
|
||||||
|
{
|
||||||
|
QJsonObject o;
|
||||||
|
QJsonArray arr;
|
||||||
|
if(lst.isEmpty())
|
||||||
|
return QJsonObject();
|
||||||
|
for(auto id:lst)
|
||||||
|
{
|
||||||
|
QJsonObject obj;
|
||||||
|
obj[sInerTag] = id.toString();
|
||||||
|
arr.push_back(obj);
|
||||||
|
}
|
||||||
|
o[sOutTag] = arr;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QUuid> FixedPortsModel::turnJsonArrToList(QJsonObject object,QString sInner,QString sOut)
|
||||||
|
{
|
||||||
|
QJsonArray jsonArray = object[sOut].toArray();
|
||||||
|
|
||||||
|
QList<QUuid> lst;
|
||||||
|
for (QJsonValueRef nodeJson : jsonArray)
|
||||||
|
{
|
||||||
|
QJsonObject node = nodeJson.toObject();
|
||||||
|
QUuid uid = QUuid(node[sInner].toString());
|
||||||
|
lst.append(uid);
|
||||||
|
}
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,10 @@ void MeasureSettingDlg::showDlg()
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->cb_equip->addItems(lstDevice);
|
ui->cb_equip->addItems(lstDevice);
|
||||||
|
BaseProperty* pro = _pBay->getProperty();
|
||||||
|
if(pro){
|
||||||
|
ui->cb_equip->setCurrentText(pro->tag());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -240,12 +240,24 @@ QMap<QString,propertyStateInfo> PropertyContentDlg::getPropertyValue(BasePropert
|
||||||
map.insert(pro.proName,info);
|
map.insert(pro.proName,info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(auto it = map.begin();it != map.end();++it) //值被手动改变过,锁定(保存后解除锁定
|
||||||
|
{
|
||||||
|
if(_curValue.contains(it.key()))
|
||||||
|
{
|
||||||
|
if(it->defaultValue != _curValue.value(it.key()).defaultValue)
|
||||||
|
{
|
||||||
|
it->lock = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyContentDlg::setPropertyValue(QVariant var)
|
void PropertyContentDlg::setPropertyValue(QVariant var)
|
||||||
{
|
{
|
||||||
QMap<QString,propertyStateInfo> map = var.value<QMap<QString,propertyStateInfo>>();
|
QMap<QString,propertyStateInfo> map = var.value<QMap<QString,propertyStateInfo>>();
|
||||||
|
_curValue = map;
|
||||||
for(auto &info:map)
|
for(auto &info:map)
|
||||||
{
|
{
|
||||||
propertyContentInfo pro = _mapPro[info.name];
|
propertyContentInfo pro = _mapPro[info.name];
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ void StatusBar::initial()
|
||||||
|
|
||||||
void StatusBar::setButtonVisible(bool val)
|
void StatusBar::setButtonVisible(bool val)
|
||||||
{
|
{
|
||||||
setVisible(m_pButtonGenerate);
|
m_pButtonGenerate->setVisible(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBar::onScaleLevelChanged(double f)
|
void StatusBar::onScaleLevelChanged(double f)
|
||||||
|
|
|
||||||
|
|
@ -443,9 +443,12 @@ void BaseSelector::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, Design
|
||||||
{
|
{
|
||||||
if(item->getItemType() == GIT_bay) //间隔暂时返回
|
if(item->getItemType() == GIT_bay) //间隔暂时返回
|
||||||
return;
|
return;
|
||||||
QString modelName = item->getModelName(); //todo:additem时填写模型类型
|
ModelProperty* pro = item->getProperty();
|
||||||
QUuid uuid = item->itemId();
|
if(pro){
|
||||||
_model->showModelDlg(modelName,uuid,item);
|
QString modelName = pro->modelName();
|
||||||
|
QUuid uuid = item->itemId();
|
||||||
|
_model->showModelDlg(modelName,uuid,item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ public:
|
||||||
QList<stationInfo> getAllStation();
|
QList<stationInfo> getAllStation();
|
||||||
|
|
||||||
QList<topologicInfo> getAllTopologics();
|
QList<topologicInfo> getAllTopologics();
|
||||||
int topologicExist(QUuid fromPin,QUuid toPin);
|
int topologicExist(QUuid fromItem,QUuid toItem);
|
||||||
topologicInfo getTopologicById(int id);
|
topologicInfo getTopologicById(int id);
|
||||||
bool deleteTopologic(QUuid fromPin,QUuid toPin);
|
bool deleteTopologic(QUuid fromPin,QUuid toPin);
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
|
|
@ -61,13 +61,23 @@ public:
|
||||||
QJsonObject getPageContextByName(QString name);
|
QJsonObject getPageContextByName(QString name);
|
||||||
QList<pageInfo> getAllPage();
|
QList<pageInfo> getAllPage();
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
bool insertMeasurement(QString tag,QString name,int type,QJsonObject dataSource,int size,int bayId,QUuid componentId);
|
bool insertBay(QUuid uuid,QString name,QString type,double unom,double fla,double capacity,QString description,bool inService,int nState,QString grid,QString zone,QString station,QJsonObject business,QJsonObject fromUuid,QJsonObject toUuid,QJsonObject protect,QJsonObject faultRec,QJsonObject status,QJsonObject dynSense,QJsonObject instruct,QJsonObject etc,QList<QUuid> components);
|
||||||
|
bool updateBay(QUuid uuid,QString name,double unom,double fla,double capacity,QString description,bool inService,int nState,QJsonObject business,QJsonObject fromUuid,QJsonObject toUuid,QJsonObject protect,QJsonObject faultRec,QJsonObject status,QJsonObject dynSense,QJsonObject instruct,QJsonObject etc,QList<QUuid> components);
|
||||||
|
bayInfo getBay(QUuid uuid);
|
||||||
|
QList<bayInfo> getAllBay();
|
||||||
|
bool ifBayExist(QUuid uuid);
|
||||||
|
bool deleteBay(QUuid uuid);
|
||||||
|
/*********************************************************************************/
|
||||||
|
bool insertMeasurement(QString name,QString tag,int type,QJsonObject dataSource,int size,QUuid bayId,QUuid componentId);
|
||||||
|
bool updateMeasurement(QString name,int type,QJsonObject dataSource,int size,QUuid componentId);
|
||||||
|
bool delteMeasurement(QString name,QUuid componentId);
|
||||||
|
bool ifMeasureExist(QString name,QUuid componentId);
|
||||||
|
QList<MeasurementInfo> getMeasurement(QUuid componentId);
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
bool deleteComponentById(int id);
|
bool deleteComponentById(int id);
|
||||||
void select();
|
|
||||||
void parallelUpdate();
|
|
||||||
|
|
||||||
QJsonObject QstringToJson(QString jsonString);
|
QJsonObject QstringToJson(QString jsonString);
|
||||||
|
QList<QUuid> parseUuidArray(const QString& pgArray); //转化UUID[]类型
|
||||||
public:
|
public:
|
||||||
//***********元模
|
//***********元模
|
||||||
bool getAttributeGroup(); //获取属性组信息
|
bool getAttributeGroup(); //获取属性组信息
|
||||||
|
|
@ -118,7 +128,9 @@ public:
|
||||||
QMap<QString,propertyGroupState> getModelInfo(const QString&); //获取模型信息
|
QMap<QString,propertyGroupState> getModelInfo(const QString&); //获取模型信息
|
||||||
QMap<QString,propertyGroupState> getPublicInfo(); //获取公共属性组信息
|
QMap<QString,propertyGroupState> getPublicInfo(); //获取公共属性组信息
|
||||||
QMap<QString,projectManager> getProjectModelGroupInfo(const QString&); //获取指定工程模所有属性组信息<属性组名,属性信息>
|
QMap<QString,projectManager> getProjectModelGroupInfo(const QString&); //获取指定工程模所有属性组信息<属性组名,属性信息>
|
||||||
QMap<QUuid,PropertyValueInfo> selectGroupProperty(const QString& tableName,QMap<QString,propertyStateInfo> mapPro); //返回属性组表中的信息
|
QMap<QUuid,PropertyValueInfo> selectGroupPropertyByState(const QString& tableName,QMap<QString,propertyStateInfo> mapPro); //返回属性组表中的信息
|
||||||
|
PropertyValueInfo selectGroupPropertyByValue(const QString& tableName,QUuid uuid,PropertyValueInfo value); //通过已有结构更新数据
|
||||||
|
|
||||||
QList<measureAttributeType> getMeasureAttributeTypes(); //获取所有量测属性
|
QList<measureAttributeType> getMeasureAttributeTypes(); //获取所有量测属性
|
||||||
private:
|
private:
|
||||||
QMap<int,attributeGroup> _attributeGroup; //属性组的组
|
QMap<int,attributeGroup> _attributeGroup; //属性组的组
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ BasePropertyManager::BasePropertyManager(QObject *parent)
|
||||||
|
|
||||||
BasePropertyManager::~BasePropertyManager()
|
BasePropertyManager::~BasePropertyManager()
|
||||||
{
|
{
|
||||||
|
qDeleteAll(m_entityData);
|
||||||
|
qDeleteAll(m_bayData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePropertyManager::insertEntityData(QUuid uid,BaseProperty* p)
|
void BasePropertyManager::insertEntityData(QUuid uid,BaseProperty* p)
|
||||||
|
|
|
||||||
|
|
@ -333,8 +333,9 @@ bool DataBase::updateDynamicProperty(QUuid uuid,groupStateValue groupValue)
|
||||||
setClauses.append(QString("%1 = ?").arg(pro.name));
|
setClauses.append(QString("%1 = ?").arg(pro.name));
|
||||||
params.append(pro.defaultValue);
|
params.append(pro.defaultValue);
|
||||||
}
|
}
|
||||||
|
params.append(uuid);
|
||||||
|
|
||||||
QString strSQL = QString("UPDATE 1% SET %2 WHERE global_uuid = 3%").arg(groupValue.tableName).arg(setClauses.join(",")).arg(uuid.toString());
|
QString strSQL = QString("UPDATE %1 SET %2 WHERE global_uuid = ?").arg(groupValue.tableName).arg(setClauses.join(","));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -660,12 +661,12 @@ QList<topologicInfo> DataBase::getAllTopologics()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DataBase::topologicExist(QUuid fromPin,QUuid toPin)
|
int DataBase::topologicExist(QUuid fromItem,QUuid toItem)
|
||||||
{
|
{
|
||||||
QString strSQL = "SELECT id FROM topologic WHERE from_pin = ? AND to_pin = ?";
|
QString strSQL = "SELECT id FROM topologic WHERE uuid_from = ? AND uuid_to = ?";
|
||||||
QVariantList params;
|
QVariantList params;
|
||||||
params.append(fromPin.toString());
|
params.append(fromItem.toString());
|
||||||
params.append(toPin.toString());
|
params.append(toItem.toString());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -754,18 +755,17 @@ componentInfo DataBase::getComponentInfoByUuid(QString uuid)
|
||||||
{
|
{
|
||||||
while (qry.next())
|
while (qry.next())
|
||||||
{
|
{
|
||||||
inf.id = qry.value(0).toInt();
|
inf.uuid = QUuid(qry.value(0).toString());
|
||||||
inf.uuid = QUuid(qry.value(1).toString());
|
inf.modelName = qry.value(1).toString();
|
||||||
inf.modelName = qry.value(2).toString();
|
inf.tag = qry.value(2).toString();
|
||||||
inf.tag = qry.value(3).toString();
|
inf.name = qry.value(3).toString();
|
||||||
inf.name = qry.value(4).toString();
|
inf.grid = qry.value(4).toString();
|
||||||
inf.grid = qry.value(5).toString();
|
inf.zone = qry.value(5).toString();
|
||||||
inf.zone = qry.value(6).toString();
|
inf.station = qry.value(6).toString();
|
||||||
inf.station = qry.value(7).toString();
|
inf.type = qry.value(7).toInt();
|
||||||
inf.type = qry.value(8).toInt();
|
QString str = qry.value(8).toString();
|
||||||
QString str = qry.value(9).toString();
|
|
||||||
inf.context = QstringToJson(str);
|
inf.context = QstringToJson(str);
|
||||||
inf.op = qry.value(10).toInt();
|
inf.op = qry.value(9).toInt();
|
||||||
qry.clear();
|
qry.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -780,7 +780,7 @@ QList<componentInfo> DataBase::getAllComponents()
|
||||||
{
|
{
|
||||||
QSqlQuery qry(db);
|
QSqlQuery qry(db);
|
||||||
|
|
||||||
qry.prepare("SELECT id, global_uuid, model_name,tag, name, grid, zone, station, type, context, op FROM component");
|
qry.prepare("SELECT global_uuid, model_name,tag, name, grid, zone, station, type, context, op FROM component");
|
||||||
bool res = qry.exec();
|
bool res = qry.exec();
|
||||||
QString str = qry.lastQuery();
|
QString str = qry.lastQuery();
|
||||||
if(!res)
|
if(!res)
|
||||||
|
|
@ -793,18 +793,17 @@ QList<componentInfo> DataBase::getAllComponents()
|
||||||
while (qry.next())
|
while (qry.next())
|
||||||
{
|
{
|
||||||
componentInfo inf;
|
componentInfo inf;
|
||||||
inf.id = qry.value(0).toInt();
|
inf.uuid = QUuid(qry.value(0).toString());
|
||||||
inf.uuid = QUuid(qry.value(1).toString());
|
inf.modelName = qry.value(1).toString();
|
||||||
inf.modelName = qry.value(2).toString();
|
inf.tag = qry.value(2).toString();
|
||||||
inf.tag = qry.value(3).toString();
|
inf.name = qry.value(3).toString();
|
||||||
inf.name = qry.value(4).toString();
|
inf.grid = qry.value(4).toString();
|
||||||
inf.grid = qry.value(5).toString();
|
inf.zone = qry.value(5).toString();
|
||||||
inf.zone = qry.value(6).toString();
|
inf.station = qry.value(6).toString();
|
||||||
inf.station = qry.value(7).toString();
|
inf.type = qry.value(7).toInt();
|
||||||
inf.type = qry.value(8).toInt();
|
QString str = qry.value(8).toString();
|
||||||
QString str = qry.value(9).toString();
|
|
||||||
inf.context = QstringToJson(str);
|
inf.context = QstringToJson(str);
|
||||||
inf.op = qry.value(10).toInt();
|
inf.op = qry.value(9).toInt();
|
||||||
lst.push_back(inf);
|
lst.push_back(inf);
|
||||||
}
|
}
|
||||||
qry.clear();
|
qry.clear();
|
||||||
|
|
@ -819,7 +818,7 @@ bool DataBase::componentExist(QString uuid)
|
||||||
{
|
{
|
||||||
QSqlQuery qry(db);
|
QSqlQuery qry(db);
|
||||||
|
|
||||||
qry.prepare("SELECT id FROM component WHERE global_uuid = ?");
|
qry.prepare("SELECT global_uuid FROM component WHERE global_uuid = ?");
|
||||||
qry.bindValue(0,uuid);
|
qry.bindValue(0,uuid);
|
||||||
bool res = qry.exec();
|
bool res = qry.exec();
|
||||||
QString str = qry.lastQuery();
|
QString str = qry.lastQuery();
|
||||||
|
|
@ -1056,11 +1055,307 @@ bool DataBase::deleteComponentById(int id)
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
bool DataBase::insertBay(QUuid uuid,QString name,QString type,double unom,double fla,double capacity,QString description,bool inService,int nState,QString grid,QString zone,
|
||||||
|
QString station,QJsonObject business,QJsonObject fromUuid,QJsonObject toUuid,QJsonObject protect,QJsonObject faultRec,QJsonObject status,QJsonObject dynSense,
|
||||||
|
QJsonObject instruct,QJsonObject etc,QList<QUuid> components)
|
||||||
|
{
|
||||||
|
QJsonDocument businessDoc(business);
|
||||||
|
QString strBusiness = businessDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument fromUuidDoc(fromUuid);
|
||||||
|
QString strFromUuid = fromUuidDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument toUuidDoc(toUuid);
|
||||||
|
QString strToUuid = toUuidDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument protectDoc(protect);
|
||||||
|
QString strProtect = protectDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument faultRecDoc(faultRec);
|
||||||
|
QString strFaultRec = faultRecDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument statusDoc(status);
|
||||||
|
QString strStatus = statusDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument dynSenseDoc(dynSense);
|
||||||
|
QString strDynSense = dynSenseDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument instructDoc(instruct);
|
||||||
|
QString strInstruct = instructDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument etcDoc(etc);
|
||||||
|
QString strEtc = etcDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QString strSQL = "INSERT INTO bay(bay_uuid, name, type, unom, fla, capacity, description, in_service, state, grid, zone, station, business, from_uuids, to_uuids, dev_protect, dev_fault_record, dev_status, dev_dyn_sense, dev_instruct, dev_etc, components) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
|
QStringList uuidStrings;
|
||||||
|
for (const QUuid &uuid : components) {
|
||||||
|
// 使用WithoutBraces确保无花括号,符合PG数组元素格式
|
||||||
|
uuidStrings << "\"" + uuid.toString(QUuid::WithoutBraces) + "\"";
|
||||||
|
}
|
||||||
|
QString arrayUuid = "{" + uuidStrings.join(",") + "}";
|
||||||
|
|
||||||
|
QVariantList params;
|
||||||
|
params.append(uuid.toString());
|
||||||
|
params.append(name);
|
||||||
|
params.append(type);
|
||||||
|
params.append(unom);
|
||||||
|
params.append(fla);
|
||||||
|
params.append(capacity);
|
||||||
|
params.append(description);
|
||||||
|
params.append(inService);
|
||||||
|
params.append(nState);
|
||||||
|
params.append(grid);
|
||||||
|
params.append(zone);
|
||||||
|
params.append(station);
|
||||||
|
params.append(strBusiness);
|
||||||
|
params.append(strFromUuid);
|
||||||
|
params.append(strToUuid);
|
||||||
|
params.append(strProtect);
|
||||||
|
params.append(strFaultRec);
|
||||||
|
params.append(strStatus);
|
||||||
|
params.append(strDynSense);
|
||||||
|
params.append(strInstruct);
|
||||||
|
params.append(strEtc);
|
||||||
|
params.append(arrayUuid);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
executeSQL(strSQL,false,params);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
LOG_ERROR("DB", QString("Insert bay fail"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBase::updateBay(QUuid uuid,QString name,double unom,double fla,double capacity,QString description,bool inService,int nState,QJsonObject business,
|
||||||
|
QJsonObject fromUuid,QJsonObject toUuid,QJsonObject protect,QJsonObject faultRec,QJsonObject status,QJsonObject dynSense,QJsonObject instruct,
|
||||||
|
QJsonObject etc,QList<QUuid> components)
|
||||||
|
{
|
||||||
|
QJsonDocument businessDoc(business);
|
||||||
|
QString strBusiness = businessDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument fromUuidDoc(fromUuid);
|
||||||
|
QString strFromUuid = fromUuidDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument toUuidDoc(toUuid);
|
||||||
|
QString strToUuid = toUuidDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument protectDoc(protect);
|
||||||
|
QString strProtect = protectDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument faultRecDoc(faultRec);
|
||||||
|
QString strFaultRec = faultRecDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument statusDoc(status);
|
||||||
|
QString strStatus = statusDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument dynSenseDoc(dynSense);
|
||||||
|
QString strDynSense = dynSenseDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument instructDoc(instruct);
|
||||||
|
QString strInstruct = instructDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument etcDoc(etc);
|
||||||
|
QString strEtc = etcDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QStringList uuidStrings;
|
||||||
|
for (const QUuid &uuid : components) {
|
||||||
|
// 使用WithoutBraces确保无花括号,符合PG数组元素格式
|
||||||
|
uuidStrings << "\"" + uuid.toString(QUuid::WithoutBraces) + "\"";
|
||||||
|
}
|
||||||
|
QString arrayUuid = "{" + uuidStrings.join(",") + "}";
|
||||||
|
|
||||||
|
QString strSQL = "UPDATE bay SET name = ?,unom = ?,fla = ?,capacity = ?,description = ?,in_service = ?, state = ?, business = ?,from_uuids = ?,to_uuids = ?,dev_protect = ?,dev_fault_record = ?, dev_status = ?,dev_dyn_sense = ?,dev_instruct = ?,dev_etc = ?,components = ? WHERE bay_uuid = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(name);
|
||||||
|
params.append(unom);
|
||||||
|
params.append(fla);
|
||||||
|
params.append(capacity);
|
||||||
|
params.append(description);
|
||||||
|
params.append(inService);
|
||||||
|
params.append(nState);
|
||||||
|
params.append(strBusiness);
|
||||||
|
params.append(strFromUuid);
|
||||||
|
params.append(strToUuid);
|
||||||
|
params.append(strProtect);
|
||||||
|
params.append(strFaultRec);
|
||||||
|
params.append(strStatus);
|
||||||
|
params.append(strDynSense);
|
||||||
|
params.append(strInstruct);
|
||||||
|
params.append(strEtc);
|
||||||
|
params.append(arrayUuid);
|
||||||
|
params.append(uuid);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
executeSQL(strSQL,false,params);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
LOG_ERROR("DB", QString("Update bay fail"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bayInfo DataBase::getBay(QUuid uuid)
|
||||||
|
{
|
||||||
|
bayInfo info;
|
||||||
|
QString strSQL = "SELECT bay_uuid, name, type, unom, fla, capacity, description, in_service, state, grid, zone, station, business, from_uuids, to_uuids, dev_protect, dev_fault_record, dev_status, dev_dyn_sense, dev_instruct, dev_etc, components FROM bay WHERE bay_uuid = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(uuid);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSqlQuery query = executeSQL(strSQL,false,params);
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
info.uuid = QUuid(query.value(0).toString());
|
||||||
|
info.name = query.value(1).toString();
|
||||||
|
info.type = query.value(2).toString();
|
||||||
|
info.unom = query.value(3).toDouble();
|
||||||
|
info.fla = query.value(4).toDouble();
|
||||||
|
info.capacity = query.value(5).toDouble();
|
||||||
|
info.description = query.value(6).toString();
|
||||||
|
info.inService = query.value(7).toBool();
|
||||||
|
info.nState = query.value(8).toInt();
|
||||||
|
info.grid = query.value(9).toString();
|
||||||
|
info.zone = query.value(10).toString();
|
||||||
|
info.station = query.value(11).toString();
|
||||||
|
QString strBusi = query.value(12).toString();
|
||||||
|
info.business = QstringToJson(strBusi);
|
||||||
|
QString strFrom = query.value(13).toString();
|
||||||
|
info.fromUuid = QstringToJson(strFrom);
|
||||||
|
QString strTo = query.value(14).toString();
|
||||||
|
info.toUuid = QstringToJson(strTo);
|
||||||
|
QString strProtect = query.value(15).toString();
|
||||||
|
info.protect = QstringToJson(strProtect);
|
||||||
|
QString strFaultRec= query.value(16).toString();
|
||||||
|
info.faultRec = QstringToJson(strFaultRec);
|
||||||
|
QString strStatus= query.value(17).toString();
|
||||||
|
info.status = QstringToJson(strStatus);
|
||||||
|
QString strDynSense= query.value(18).toString();
|
||||||
|
info.dynSense = QstringToJson(strDynSense);
|
||||||
|
QString strInstructe= query.value(19).toString();
|
||||||
|
info.instruct = QstringToJson(strInstructe);
|
||||||
|
QString strEtc= query.value(20).toString();
|
||||||
|
info.etc = QstringToJson(strEtc);
|
||||||
|
QString rawData = query.value(21).toString();
|
||||||
|
info.components = parseUuidArray(rawData);
|
||||||
|
}
|
||||||
|
query.clear();
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<bayInfo> DataBase::getAllBay()
|
||||||
|
{
|
||||||
|
QList<bayInfo> lstInfo;
|
||||||
|
QString strSQL = "SELECT bay_uuid, name, type, unom, fla, capacity, description, in_service, state, grid, zone, station, business, from_uuids, to_uuids, dev_protect, dev_fault_record, dev_status, dev_dyn_sense, dev_instruct, dev_etc, components FROM bay";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSqlQuery query = executeSQL(strSQL);
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
bayInfo info;
|
||||||
|
info.uuid = QUuid(query.value(0).toString());
|
||||||
|
info.name = query.value(1).toString();
|
||||||
|
info.type = query.value(2).toString();
|
||||||
|
info.unom = query.value(3).toDouble();
|
||||||
|
info.fla = query.value(4).toDouble();
|
||||||
|
info.capacity = query.value(5).toDouble();
|
||||||
|
info.description = query.value(6).toString();
|
||||||
|
info.inService = query.value(7).toBool();
|
||||||
|
info.nState = query.value(8).toInt();
|
||||||
|
info.grid = query.value(9).toString();
|
||||||
|
info.zone = query.value(10).toString();
|
||||||
|
info.station = query.value(11).toString();
|
||||||
|
QString strBusi = query.value(12).toString();
|
||||||
|
info.business = QstringToJson(strBusi);
|
||||||
|
QString strFrom = query.value(13).toString();
|
||||||
|
info.fromUuid = QstringToJson(strFrom);
|
||||||
|
QString strTo = query.value(14).toString();
|
||||||
|
info.toUuid = QstringToJson(strTo);
|
||||||
|
QString strProtect = query.value(15).toString();
|
||||||
|
info.protect = QstringToJson(strProtect);
|
||||||
|
QString strFaultRec= query.value(16).toString();
|
||||||
|
info.faultRec = QstringToJson(strFaultRec);
|
||||||
|
QString strStatus= query.value(17).toString();
|
||||||
|
info.status = QstringToJson(strStatus);
|
||||||
|
QString strDynSense= query.value(18).toString();
|
||||||
|
info.dynSense = QstringToJson(strDynSense);
|
||||||
|
QString strInstructe= query.value(19).toString();
|
||||||
|
info.instruct = QstringToJson(strInstructe);
|
||||||
|
QString strEtc= query.value(20).toString();
|
||||||
|
info.etc = QstringToJson(strEtc);
|
||||||
|
QString rawData = query.value(21).toString();
|
||||||
|
info.components = parseUuidArray(rawData);
|
||||||
|
lstInfo.append(info);
|
||||||
|
}
|
||||||
|
query.clear();
|
||||||
|
return lstInfo;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return lstInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBase::ifBayExist(QUuid uuid)
|
||||||
|
{
|
||||||
|
QString strSQL = "SELECT bay_uuid FROM bay WHERE bay_uuid = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(uuid);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSqlQuery query = executeSQL(strSQL,false,params);
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBase::deleteBay(QUuid uuid)
|
||||||
|
{
|
||||||
|
QString strSQL = "DELETE FROM bay WHERE bay_uuid = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(uuid);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
executeSQL(strSQL,false,params);
|
||||||
|
LOG_INFO("DB", QString("Delete bay %1 success").arg(uuid.toString()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
LOG_ERROR("DB", QString("Delete bay %1 failed").arg(uuid.toString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
bool DataBase::insertMeasurement(QString tag,QString name,int type,QJsonObject dataSource,int size,int bayId,QUuid componentId)
|
bool DataBase::insertMeasurement(QString name,QString tag,int type,QJsonObject dataSource,int size,QUuid bayId,QUuid componentId)
|
||||||
{
|
{
|
||||||
QString strSQL = "INSERT INTO measurement(tag, name, type, data_source, size, bay_id, component_id) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
QString strSQL = "INSERT INTO measurement(tag, name, type, data_source, size, bay_uuid, component_uuid) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||||
QJsonDocument dataDoc(dataSource);
|
QJsonDocument dataDoc(dataSource);
|
||||||
QString strData = dataDoc.toJson(QJsonDocument::Compact);
|
QString strData = dataDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
|
@ -1084,18 +1379,109 @@ bool DataBase::insertMeasurement(QString tag,QString name,int type,QJsonObject d
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DataBase::updateMeasurement(QString name,int type,QJsonObject dataSource,int size,QUuid componentId)
|
||||||
|
{
|
||||||
|
QJsonDocument dataDoc(dataSource);
|
||||||
|
QString strData = dataDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QString strSQL = "UPDATE measurement SET type = ?,data_source = ?,size = ? WHERE name = ? AND component_uuid = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(type);
|
||||||
|
params.append(strData);
|
||||||
|
params.append(size);
|
||||||
|
params.append(name);
|
||||||
|
params.append(componentId);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
executeSQL(strSQL,false,params);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
LOG_ERROR("DB", QString("Update measurement %1 fail").arg(name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBase::delteMeasurement(QString name,QUuid componentId)
|
||||||
|
{
|
||||||
|
QString strSQL = "DELETE FROM measurement WHERE name = ? AND component_uuid = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(name);
|
||||||
|
params.append(componentId);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
executeSQL(strSQL,false,params);
|
||||||
|
LOG_INFO("DB", QString("Delete measurement %1 success").arg(name));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
LOG_ERROR("DB", QString("Delete measurement %1 failed").arg(name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBase::ifMeasureExist(QString name,QUuid componentId)
|
||||||
|
{
|
||||||
|
QString strSQL = "SELECT id FROM measurement WHERE name = ? AND component_uuid = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(name);
|
||||||
|
params.append(componentId);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSqlQuery query = executeSQL(strSQL,false,params);
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<MeasurementInfo> DataBase::getMeasurement(QUuid componentId)
|
||||||
|
{
|
||||||
|
QList<MeasurementInfo> lst;
|
||||||
|
QString strSQL = "SELECT tag, name, type, data_source, size, bay_uuid, component_uuid FROM measurement WHERE component_uuid = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(componentId);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSqlQuery query = executeSQL(strSQL,false,params);
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
MeasurementInfo info;
|
||||||
|
info.tag = query.value(0).toString();
|
||||||
|
info.name = query.value(1).toString();
|
||||||
|
info.type = query.value(2).toString();
|
||||||
|
QString con = query.value(3).toString();
|
||||||
|
QJsonObject obj = QstringToJson(con);
|
||||||
|
info.equipment = obj["type"].toString();
|
||||||
|
info.channel = obj["main_pos"].toString();
|
||||||
|
info.size = query.value(4).toInt();
|
||||||
|
info.bayUuid = QUuid(query.value(5).toString());
|
||||||
|
info.componentUuid = QUuid(query.value(6).toString());
|
||||||
|
lst.append(info);
|
||||||
|
}
|
||||||
|
query.clear();
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
}
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void DataBase::select()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataBase::parallelUpdate()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataBase::readXML()
|
void DataBase::readXML()
|
||||||
{
|
{
|
||||||
if (m_sFileName.isEmpty())
|
if (m_sFileName.isEmpty())
|
||||||
|
|
@ -1173,6 +1559,35 @@ QJsonObject DataBase::QstringToJson(QString jsonString)
|
||||||
QJsonObject jsonObject = jsonDocument.object();
|
QJsonObject jsonObject = jsonDocument.object();
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QUuid> DataBase::parseUuidArray(const QString& pgArray)
|
||||||
|
{
|
||||||
|
QList<QUuid> uuids;
|
||||||
|
|
||||||
|
if (pgArray.isEmpty() || pgArray == "{}")
|
||||||
|
return uuids;
|
||||||
|
|
||||||
|
// 移除花括号并分割元素
|
||||||
|
QStringList parts = pgArray.mid(1, pgArray.size() - 2).split(",");
|
||||||
|
|
||||||
|
for (QString& part : parts) {
|
||||||
|
part = part.trimmed();
|
||||||
|
|
||||||
|
// 处理带双引号的元素
|
||||||
|
if (part.startsWith('"') && part.endsWith('"')) {
|
||||||
|
part = part.mid(1, part.size() - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理 NULL 值(转为空 QUuid)
|
||||||
|
if (part == "NULL") {
|
||||||
|
uuids << QUuid();
|
||||||
|
} else {
|
||||||
|
uuids << QUuid(part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return uuids;
|
||||||
|
}
|
||||||
//=================================元模=============================================//
|
//=================================元模=============================================//
|
||||||
bool DataBase::getAttributeGroup()
|
bool DataBase::getAttributeGroup()
|
||||||
{
|
{
|
||||||
|
|
@ -1889,7 +2304,7 @@ QMap<QString,projectManager> DataBase::getProjectModelGroupInfo(const QString& s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QUuid,PropertyValueInfo> DataBase::selectGroupProperty(const QString& tableName,QMap<QString,propertyStateInfo> mapPro)
|
QMap<QUuid,PropertyValueInfo> DataBase::selectGroupPropertyByState(const QString& tableName,QMap<QString,propertyStateInfo> mapPro)
|
||||||
{
|
{
|
||||||
QStringList paramList;
|
QStringList paramList;
|
||||||
for(auto &pro:mapPro)
|
for(auto &pro:mapPro)
|
||||||
|
|
@ -1920,6 +2335,7 @@ QMap<QUuid,PropertyValueInfo> DataBase::selectGroupProperty(const QString& table
|
||||||
}
|
}
|
||||||
pro.name = proVal.name;
|
pro.name = proVal.name;
|
||||||
pro.type = proVal.type;
|
pro.type = proVal.type;
|
||||||
|
pro.isVisibe = proVal.isVisibe;
|
||||||
pro.defaultValue = query.value(proVal.name );
|
pro.defaultValue = query.value(proVal.name );
|
||||||
info.insert(proVal.name ,pro);
|
info.insert(proVal.name ,pro);
|
||||||
}
|
}
|
||||||
|
|
@ -1934,6 +2350,43 @@ QMap<QUuid,PropertyValueInfo> DataBase::selectGroupProperty(const QString& table
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PropertyValueInfo DataBase::selectGroupPropertyByValue(const QString& tableName,QUuid uuid,PropertyValueInfo value)
|
||||||
|
{
|
||||||
|
PropertyValueInfo map;
|
||||||
|
QStringList paramList;
|
||||||
|
for(auto &pro:value)
|
||||||
|
{
|
||||||
|
paramList.append(pro.name);
|
||||||
|
}
|
||||||
|
QString strSQL = QString("SELECT %1 FROM %2 WHERE global_uuid = ?").arg(paramList.join(", ")).arg(tableName);
|
||||||
|
QVariantList params;
|
||||||
|
params.append(uuid);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSqlQuery query = executeSQL(strSQL,false,params);
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
QUuid uuid;
|
||||||
|
for(auto &proVal:value)
|
||||||
|
{
|
||||||
|
propertyStateInfo pro;
|
||||||
|
pro.name = proVal.name;
|
||||||
|
pro.type = proVal.type;
|
||||||
|
pro.isVisibe = proVal.isVisibe;
|
||||||
|
pro.defaultValue = query.value(proVal.name );
|
||||||
|
map.insert(proVal.name,pro);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
query.clear();
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QList<measureAttributeType> DataBase::getMeasureAttributeTypes()
|
QList<measureAttributeType> DataBase::getMeasureAttributeTypes()
|
||||||
{
|
{
|
||||||
QList<measureAttributeType> lst;
|
QList<measureAttributeType> lst;
|
||||||
|
|
|
||||||
|
|
@ -62,12 +62,14 @@ void DataManager::initialModelState(bool refresh)
|
||||||
QString dataType = node["type"].toString();
|
QString dataType = node["type"].toString();
|
||||||
QVariant defaultValue = node["defaultValue"].toVariant();
|
QVariant defaultValue = node["defaultValue"].toVariant();
|
||||||
int lengthPrecision = node["lengthPrecision"].toInt();
|
int lengthPrecision = node["lengthPrecision"].toInt();
|
||||||
|
int nIsVisible = node["isVisible"].toInt();
|
||||||
if(nState)
|
if(nState)
|
||||||
{
|
{
|
||||||
propertyInfo.name = propertyName;
|
propertyInfo.name = propertyName;
|
||||||
propertyInfo.type = dataType;
|
propertyInfo.type = dataType;
|
||||||
propertyInfo.defaultValue = defaultValue;
|
propertyInfo.defaultValue = defaultValue;
|
||||||
propertyInfo.lengthPrecision = lengthPrecision;
|
propertyInfo.lengthPrecision = lengthPrecision;
|
||||||
|
propertyInfo.isVisibe = nIsVisible;
|
||||||
|
|
||||||
groupInfo.info.insert(propertyName,propertyInfo);
|
groupInfo.info.insert(propertyName,propertyInfo);
|
||||||
}
|
}
|
||||||
|
|
@ -92,6 +94,7 @@ void DataManager::initialModelState(bool refresh)
|
||||||
QString dataType = node["type"].toString();
|
QString dataType = node["type"].toString();
|
||||||
QVariant defaultValue = node["defaultValue"].toVariant();
|
QVariant defaultValue = node["defaultValue"].toVariant();
|
||||||
int lengthPrecision = node["lengthPrecision"].toInt();
|
int lengthPrecision = node["lengthPrecision"].toInt();
|
||||||
|
int nIsVisible = node["isVisible"].toInt();
|
||||||
if(nState)
|
if(nState)
|
||||||
{
|
{
|
||||||
//todo:别名赋值
|
//todo:别名赋值
|
||||||
|
|
@ -99,6 +102,7 @@ void DataManager::initialModelState(bool refresh)
|
||||||
propertyInfo.type = dataType;
|
propertyInfo.type = dataType;
|
||||||
propertyInfo.defaultValue = defaultValue;
|
propertyInfo.defaultValue = defaultValue;
|
||||||
propertyInfo.lengthPrecision = lengthPrecision;
|
propertyInfo.lengthPrecision = lengthPrecision;
|
||||||
|
propertyInfo.isVisibe = nIsVisible;
|
||||||
|
|
||||||
groupInfo.info.insert(propertyName,propertyInfo);
|
groupInfo.info.insert(propertyName,propertyInfo);
|
||||||
}
|
}
|
||||||
|
|
@ -114,94 +118,117 @@ void DataManager::initialModelState(bool refresh)
|
||||||
void DataManager::initialModelData(bool refresh)
|
void DataManager::initialModelData(bool refresh)
|
||||||
{
|
{
|
||||||
QMap<QString,int> model = DataBase::GetInstance()->getAllProjectModel();
|
QMap<QString,int> model = DataBase::GetInstance()->getAllProjectModel();
|
||||||
if(refresh)
|
if(!refresh){
|
||||||
{
|
QMap<QString,int>::Iterator iter;
|
||||||
_modleDataInfo.clear();
|
for(iter = model.begin();iter != model.end(); ++iter) //遍历模型
|
||||||
}
|
|
||||||
QMap<QString,int>::Iterator iter;
|
|
||||||
for(iter = model.begin();iter != model.end(); ++iter) //遍历模型
|
|
||||||
{
|
|
||||||
modelDataInfo modelInfo;
|
|
||||||
modelInfo.modelType = iter.value(); //模型类型
|
|
||||||
modelInfo.modelName = iter.key();
|
|
||||||
|
|
||||||
QMap<QString,propertyGroupState> mapState = DataBase::GetInstance()->getModelInfo(iter.key());
|
|
||||||
QMap<QString,propertyGroupState> mapPublic = DataBase::GetInstance()->getPublicInfo(); //公共属性组
|
|
||||||
QMap<QString,propertyGroupState>::Iterator it;
|
|
||||||
|
|
||||||
for(it = mapPublic.begin();it != mapPublic.end();++it) //遍历公共属性组
|
|
||||||
{
|
{
|
||||||
groupStateValue groupValue;
|
modelDataInfo modelInfo;
|
||||||
groupValue.groupName = it.key();
|
modelInfo.modelType = iter.value(); //模型类型
|
||||||
groupValue.tableName = it->tableName;
|
modelInfo.modelName = iter.key();
|
||||||
QJsonArray nodesJsonArray = it->propertyState["checkState"].toArray();
|
|
||||||
|
|
||||||
QMap<QString,propertyStateInfo> mapPro;
|
QMap<QString,propertyGroupState> mapState = DataBase::GetInstance()->getModelInfo(iter.key());
|
||||||
for (QJsonValueRef nodeJson : nodesJsonArray) //每个属性的状态信息
|
QMap<QString,propertyGroupState> mapPublic = DataBase::GetInstance()->getPublicInfo(); //公共属性组
|
||||||
|
QMap<QString,propertyGroupState>::Iterator it;
|
||||||
|
|
||||||
|
for(it = mapPublic.begin();it != mapPublic.end();++it) //遍历公共属性组
|
||||||
{
|
{
|
||||||
propertyStateInfo propertyInfo;
|
groupStateValue groupValue;
|
||||||
|
groupValue.groupName = it.key();
|
||||||
|
groupValue.tableName = it->tableName;
|
||||||
|
QJsonArray nodesJsonArray = it->propertyState["checkState"].toArray();
|
||||||
|
|
||||||
QJsonObject node = nodeJson.toObject();
|
QMap<QString,propertyStateInfo> mapPro;
|
||||||
QString propertyName = node["name"].toString();
|
for (QJsonValueRef nodeJson : nodesJsonArray) //每个属性的状态信息
|
||||||
int nState = node["checked"].toInt();
|
|
||||||
QString dataType = node["type"].toString();
|
|
||||||
QVariant defaultValue = node["defaultValue"].toVariant();
|
|
||||||
|
|
||||||
propertyInfo.name = propertyName;
|
|
||||||
propertyInfo.type = dataType;
|
|
||||||
if(nState)
|
|
||||||
{
|
{
|
||||||
mapPro.insert(propertyName,propertyInfo);
|
propertyStateInfo propertyInfo;
|
||||||
|
|
||||||
|
QJsonObject node = nodeJson.toObject();
|
||||||
|
QString propertyName = node["name"].toString();
|
||||||
|
int nState = node["checked"].toInt();
|
||||||
|
QString dataType = node["type"].toString();
|
||||||
|
QVariant defaultValue = node["defaultValue"].toVariant();
|
||||||
|
int nIsVisible = node["isVisible"].toInt();
|
||||||
|
|
||||||
|
propertyInfo.name = propertyName;
|
||||||
|
propertyInfo.type = dataType;
|
||||||
|
propertyInfo.isVisibe = nIsVisible;
|
||||||
|
if(nState)
|
||||||
|
{
|
||||||
|
mapPro.insert(propertyName,propertyInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if(!mapPro.contains("global_uuid")) //不包含uuid则手动添加
|
||||||
|
{
|
||||||
|
propertyStateInfo uuidInfo;
|
||||||
|
uuidInfo.name = "global_uuid"; //全局id未添加到属性状态中,手动添加
|
||||||
|
mapPro.insert("global_uuid",uuidInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
groupValue.mapInfo = DataBase::GetInstance()->selectGroupPropertyByState(it->tableName,mapPro); //返回表中属性值
|
||||||
|
|
||||||
|
modelInfo.groupInfo.insert(it.key(),groupValue);
|
||||||
}
|
}
|
||||||
if(!mapPro.contains("global_uuid")) //不包含uuid则手动添加
|
|
||||||
|
for(it = mapState.begin();it != mapState.end();++it) //遍历模型属性组
|
||||||
{
|
{
|
||||||
|
groupStateValue groupValue;
|
||||||
|
groupValue.groupName = it.key();
|
||||||
|
groupValue.tableName = it->tableName;
|
||||||
|
QJsonArray nodesJsonArray = it->propertyState["checkState"].toArray();
|
||||||
|
|
||||||
|
QMap<QString,propertyStateInfo> mapPro;
|
||||||
|
for (QJsonValueRef nodeJson : nodesJsonArray) //每个属性的状态信息
|
||||||
|
{
|
||||||
|
propertyStateInfo propertyInfo;
|
||||||
|
|
||||||
|
QJsonObject node = nodeJson.toObject();
|
||||||
|
QString propertyName = node["name"].toString();
|
||||||
|
int nState = node["checked"].toInt();
|
||||||
|
QString dataType = node["type"].toString();
|
||||||
|
QVariant defaultValue = node["defaultValue"].toVariant();
|
||||||
|
int nIsVisible = node["isVisible"].toInt();
|
||||||
|
|
||||||
|
propertyInfo.name = propertyName;
|
||||||
|
propertyInfo.type = dataType;
|
||||||
|
propertyInfo.isVisibe = nIsVisible;
|
||||||
|
if(nState)
|
||||||
|
{
|
||||||
|
mapPro.insert(propertyName,propertyInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
propertyStateInfo uuidInfo;
|
propertyStateInfo uuidInfo;
|
||||||
uuidInfo.name = "global_uuid"; //全局id未添加到属性状态中,手动添加
|
uuidInfo.name = "global_uuid"; //全局id未添加到属性状态中,手动添加
|
||||||
mapPro.insert("global_uuid",uuidInfo);
|
mapPro.insert("global_uuid",uuidInfo);
|
||||||
|
|
||||||
|
groupValue.mapInfo = DataBase::GetInstance()->selectGroupPropertyByState(it->tableName,mapPro); //返回表中属性值
|
||||||
|
|
||||||
|
modelInfo.groupInfo.insert(it.key(),groupValue);
|
||||||
}
|
}
|
||||||
|
_modleDataInfo.insert(iter.key(),modelInfo);
|
||||||
groupValue.mapInfo = DataBase::GetInstance()->selectGroupProperty(it->tableName,mapPro); //返回表中属性值
|
|
||||||
|
|
||||||
modelInfo.groupInfo.insert(it.key(),groupValue);
|
|
||||||
}
|
}
|
||||||
|
_dataInitialised = true;
|
||||||
for(it = mapState.begin();it != mapState.end();++it) //遍历模型属性组
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(auto itMod = _modleDataInfo.begin();itMod != _modleDataInfo.end();itMod++) //模型
|
||||||
{
|
{
|
||||||
groupStateValue groupValue;
|
for(auto itGroup = itMod->groupInfo.begin();itGroup != itMod->groupInfo.end();itGroup++) //属性组
|
||||||
groupValue.groupName = it.key();
|
|
||||||
groupValue.tableName = it->tableName;
|
|
||||||
QJsonArray nodesJsonArray = it->propertyState["checkState"].toArray();
|
|
||||||
|
|
||||||
QMap<QString,propertyStateInfo> mapPro;
|
|
||||||
for (QJsonValueRef nodeJson : nodesJsonArray) //每个属性的状态信息
|
|
||||||
{
|
{
|
||||||
propertyStateInfo propertyInfo;
|
for(auto itComponent = itGroup->mapInfo.begin();itComponent != itGroup->mapInfo.end();itComponent++) //设备
|
||||||
|
|
||||||
QJsonObject node = nodeJson.toObject();
|
|
||||||
QString propertyName = node["name"].toString();
|
|
||||||
int nState = node["checked"].toInt();
|
|
||||||
QString dataType = node["type"].toString();
|
|
||||||
QVariant defaultValue = node["defaultValue"].toVariant();
|
|
||||||
|
|
||||||
propertyInfo.name = propertyName;
|
|
||||||
propertyInfo.type = dataType;
|
|
||||||
if(nState)
|
|
||||||
{
|
{
|
||||||
mapPro.insert(propertyName,propertyInfo);
|
//获取component对应id的属性
|
||||||
|
PropertyValueInfo info = DataBase::GetInstance()->selectGroupPropertyByValue(itGroup->tableName,itComponent.key(),itComponent.value());
|
||||||
|
for(auto itPro = itComponent->begin(); itPro != itComponent->end();itPro++) //属性
|
||||||
|
{
|
||||||
|
if(info.contains(itPro.key())){
|
||||||
|
if(!itPro->lock)
|
||||||
|
itPro->defaultValue = info.value(itPro.key()).defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
propertyStateInfo uuidInfo;
|
|
||||||
uuidInfo.name = "global_uuid"; //全局id未添加到属性状态中,手动添加
|
|
||||||
mapPro.insert("global_uuid",uuidInfo);
|
|
||||||
|
|
||||||
groupValue.mapInfo = DataBase::GetInstance()->selectGroupProperty(it->tableName,mapPro); //返回表中属性值
|
|
||||||
|
|
||||||
modelInfo.groupInfo.insert(it.key(),groupValue);
|
|
||||||
}
|
}
|
||||||
_modleDataInfo.insert(iter.key(),modelInfo);
|
|
||||||
}
|
}
|
||||||
_dataInitialised = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::updateModelData(const QString& sModel,QUuid uuid,const QString& sGroup,QMap<QString,propertyStateInfo> mapPro)
|
void DataManager::updateModelData(const QString& sModel,QUuid uuid,const QString& sGroup,QMap<QString,propertyStateInfo> mapPro)
|
||||||
|
|
|
||||||
|
|
@ -401,6 +401,8 @@ QStringList ProjectModelManager::getAttributeList(const QString& sM,const QStrin
|
||||||
{
|
{
|
||||||
if(mt.modelTypeId == metaId && mt.attributeGroupId == groupId)
|
if(mt.modelTypeId == metaId && mt.attributeGroupId == groupId)
|
||||||
{
|
{
|
||||||
|
if(attMap[mt.attributeId].isVisible == 2) //2为特殊属性,不加入选择
|
||||||
|
continue;
|
||||||
lst.append(attMap[mt.attributeId].attribute);
|
lst.append(attMap[mt.attributeId].attribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,15 +32,16 @@ void DiagramView::initial()
|
||||||
// 设置模型的列数
|
// 设置模型的列数
|
||||||
_pModel->setColumnCount(1);
|
_pModel->setColumnCount(1);
|
||||||
|
|
||||||
QList<QStandardItem*> pageList;
|
//QList<QStandardItem*> pageList;
|
||||||
QList<pageInfo> lst = DataBase::GetInstance()->getAllPage();
|
QList<pageInfo> lst = DataBase::GetInstance()->getAllPage();
|
||||||
for(auto info:lst)
|
for(auto info:lst)
|
||||||
{
|
{
|
||||||
QStandardItem* pItem = new QStandardItem(info.name);
|
QStandardItem* pItem = new QStandardItem(info.name);
|
||||||
pItem->setData(info.id,Qt::UserRole);
|
pItem->setData(info.id,Qt::UserRole);
|
||||||
pageList.append(pItem);
|
//pageList.append(pItem);
|
||||||
|
_pModel->appendRow(pItem);
|
||||||
}
|
}
|
||||||
_pModel->appendRow(pageList);
|
//_pModel->appendRow(pageList);
|
||||||
|
|
||||||
// 创建树视图
|
// 创建树视图
|
||||||
ui->treeView->setModel(_pModel);
|
ui->treeView->setModel(_pModel);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue