finish load project model
This commit is contained in:
parent
29ab9aa5f4
commit
c9244b57fd
|
|
@ -29,8 +29,8 @@ enum GraphicsItemType
|
|||
|
||||
enum AbstractItemType //工程模关联的对象类型
|
||||
{
|
||||
AIT_bus = 1,
|
||||
AIT_motor
|
||||
AIT_motor = 1,
|
||||
AIT_bus
|
||||
};
|
||||
|
||||
class corresbondItem //类型关联函数
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
|
||||
QMap<AbstractItemType,GraphicsItemType> corresbondItem::linkType = {
|
||||
{AIT_bus,GIT_bus},
|
||||
{AIT_motor,GIT_itemRect},{AIT_bus,GIT_bus},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public:
|
|||
void setTopWidget(DrawingPanel* p) {_widget = p;}
|
||||
QWidget* getTopWidget();
|
||||
|
||||
void showModelDlg(const QString&,QUuid); //点击时显示指定模型的dlg、指定item的数据(模型名,对象Uuid)
|
||||
void showModelDlg(const QString&,QUuid,GraphicsBaseItem*); //点击时显示指定模型的dlg、指定item的数据(模型名,对象Uuid,触发事件的item)
|
||||
void initialPropertyDlg(); //初始化属性设置dlg,每个模型拥各自的dlg
|
||||
void generatePropertyDlg(const QString&);
|
||||
Q_SIGNALS:
|
||||
|
|
@ -64,6 +64,7 @@ private:
|
|||
QTimer* _timer;
|
||||
|
||||
QMap<QString,modelStateInfo> _modelStateInfo; //模型结构信息
|
||||
QMap<QString,modelDataInfo> _modelDataInfo; //模型数据信息
|
||||
public:
|
||||
static bool _dataInitialised;
|
||||
static QMap<QUuid,BaseProperty*> _nodeData; //一个data可对应多个item
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public:
|
|||
ElectricSvgItemRect(const QRect &rect, QGraphicsItem *parent = 0);
|
||||
virtual ~ElectricSvgItemRect();
|
||||
|
||||
virtual void updateByProperty();
|
||||
//virtual void updateByProperty();
|
||||
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||
|
|
|
|||
|
|
@ -586,9 +586,8 @@ class VariableProperty:public BaseProperty //收到的变量数据
|
|||
public:
|
||||
VariableProperty(QObject* parent);
|
||||
~VariableProperty();
|
||||
QMap<QString,VariableMap>& getMapGroup() {return _MapGroup;}
|
||||
private:
|
||||
QMap<QString,VariableMap> _MapGroup; //<属性组,属性集>
|
||||
|
||||
modelDataInfo getPropertyValue() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ QT_BEGIN_NAMESPACE
|
|||
namespace Ui { class itemPropertyDlg; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class GraphicsBaseItem;
|
||||
|
||||
struct PropertyInfo
|
||||
{
|
||||
double resistance = 0; //电阻 DEFAULT 2,
|
||||
|
|
@ -34,7 +36,7 @@ public:
|
|||
void initial();
|
||||
void loadGroupButton(QMap<QString,groupStateInfo>); //加载属性组列表
|
||||
void createGroupView(const QString&); //创建属性页
|
||||
void showDlg(modelDataInfo,QUuid); //显示属性页面
|
||||
void showDlg(modelDataInfo,QUuid,GraphicsBaseItem*); //显示属性页面
|
||||
signals:
|
||||
void PropertyChange(const PropertyInfo);
|
||||
public slots:
|
||||
|
|
@ -53,6 +55,7 @@ private:
|
|||
QMap<QString,groupStateValue> groupValue_; //属性数据
|
||||
QUuid curUuid_; //当前显示对象的uuid
|
||||
QString _curModel; //当前模型名
|
||||
GraphicsBaseItem* _curItem;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ private:
|
|||
|
||||
QMap<QString,propertyContentInfo> _mapPro;
|
||||
private:
|
||||
QFormLayout* createFormLayout();
|
||||
QFormLayout* createFormLayout(QWidget* parent);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ FixedPortsModel::FixedPortsModel()
|
|||
_timer = new QTimer(this);
|
||||
|
||||
_modelStateInfo = DataManager::instance().modelState();
|
||||
_modelDataInfo = DataManager::instance().modelData();
|
||||
initialPropertyDlg();
|
||||
connect(_timer,SIGNAL(timeout()),this,SLOT(onTimeOut()));
|
||||
connect(_Interface,&HttpInterface::sendPointData,this,&FixedPortsModel::onSignal_GetPointData);
|
||||
|
|
@ -140,25 +141,9 @@ BaseProperty* FixedPortsModel::addNodeData(QUuid id,int type,QString name,QStrin
|
|||
{
|
||||
if(_nodeData.contains(id))
|
||||
return nullptr;
|
||||
modelStateInfo modelInfo;
|
||||
for(auto &model:_modelStateInfo){ //找到对象对应的工程模
|
||||
if(model.modelName == modelName){
|
||||
modelInfo = model;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
VariableProperty* item = new VariableProperty(this);
|
||||
QMap<QString,VariableMap>& propertyGroup = item->getMapGroup();
|
||||
for(auto &groupInfo:modelInfo.groupInfo)
|
||||
{
|
||||
VariableMap map;
|
||||
for(auto &pro:groupInfo.info)
|
||||
{
|
||||
map.insert(pro.name,pro.defaultValue); //添加属性信息
|
||||
}
|
||||
propertyGroup.insert(groupInfo.groupName,map);
|
||||
}
|
||||
//todo:关联到对应data
|
||||
|
||||
if(item)
|
||||
{
|
||||
|
|
@ -195,28 +180,6 @@ void FixedPortsModel::loadNodeDataFromDataBase()
|
|||
pData->setStation(info.station);
|
||||
pData->setDataChanged(false);
|
||||
|
||||
VariableProperty* pPro = dynamic_cast<VariableProperty*>(pData);
|
||||
if(pPro)
|
||||
{
|
||||
QMap<QString,VariableMap>& mapVariableGroup = pPro->getMapGroup();
|
||||
ModelDataMap mapData = DataManager::instance().modelData();
|
||||
|
||||
QMap<QString,groupStateValue> mapGroup = mapData[info.modelName].groupInfo; //取得该模型下的所有属性组
|
||||
QMap<QString,groupStateValue>::Iterator iter;
|
||||
for(iter = mapGroup.begin();iter != mapGroup.end();++iter)
|
||||
{
|
||||
VariableMap varMap;
|
||||
|
||||
PropertyValueInfo valueInfo = iter->mapInfo[info.uuid];
|
||||
PropertyValueInfo::Iterator it;
|
||||
for(it = valueInfo.begin(); it != valueInfo.end();++it)
|
||||
{
|
||||
varMap.insert(it.key(),it->defaultValue);
|
||||
}
|
||||
|
||||
mapVariableGroup.insert(iter.key(),varMap);
|
||||
}
|
||||
}
|
||||
|
||||
if(info.type == GIT_itemTri)
|
||||
{
|
||||
|
|
@ -224,7 +187,7 @@ void FixedPortsModel::loadNodeDataFromDataBase()
|
|||
}
|
||||
else if(info.type == GIT_itemRect)
|
||||
{
|
||||
busStability bility = DataBase::GetInstance()->getBusStabilityById(info.id);
|
||||
//busStability bility = DataBase::GetInstance()->getBusStabilityById(info.id);
|
||||
/*ElectricSvgItemRect_Property* pPro = dynamic_cast<ElectricSvgItemRect_Property*>(pData);
|
||||
if(pPro)
|
||||
{
|
||||
|
|
@ -464,31 +427,25 @@ void FixedPortsModel::saveNode(int nPageId)
|
|||
if(pData->dataChanged())
|
||||
{
|
||||
bool exist = DataBase::GetInstance()->componentExist(pData->uuid().toString());
|
||||
if(exist) //已存在更新
|
||||
VariableProperty* pVariable = dynamic_cast<VariableProperty*>(pData);
|
||||
if(pVariable)
|
||||
{
|
||||
DataBase::GetInstance()->updateComponent(pData->uuid(),pData->tag(),pData->name(),pData->context());
|
||||
int type = pData->type();
|
||||
if(type == GIT_itemRect)
|
||||
modelDataInfo dataInfo = pVariable->getPropertyValue();
|
||||
if(exist) //已存在更新
|
||||
{
|
||||
/*ElectricSvgItemRect_Property* pro = dynamic_cast<ElectricSvgItemRect_Property*>(pData);
|
||||
if(pro)
|
||||
DataBase::GetInstance()->updateComponent(pData->uuid(),pData->tag(),pData->name(),pData->context());
|
||||
for(auto &val:dataInfo.groupInfo)
|
||||
{
|
||||
DataBase::GetInstance()->updateBus_stability(pro->component_id(),pro->getResistance(),pro->getAnchor_v(),pro->getUv_alarm(),pro->getOv_alarm(),pro->getAnchor_i(),pro->getUi_alarm(),pro->getOi_alarm(),1);
|
||||
}*/
|
||||
DataBase::GetInstance()->updateDynamicProperty(pData->uuid(),val);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DataBase::GetInstance()->insertComponent(pData->uuid(),pData->modelName(),pData->path(),pData->tag(),pData->name(),pData->description(),pData->grid(),pData->zone(),pData->station(),pData->type(),true,pData->state(),pData->connectedBus(),pData->label(),pData->context(),nPageId,1);
|
||||
int type = pData->type();
|
||||
if(type == GIT_itemRect)
|
||||
else
|
||||
{
|
||||
/*ElectricSvgItemRect_Property* pro = dynamic_cast<ElectricSvgItemRect_Property*>(pData);
|
||||
if(pro)
|
||||
DataBase::GetInstance()->insertComponent(pData->uuid(),pData->modelName(),pData->path(),pData->tag(),pData->name(),pData->description(),pData->grid(),pData->zone(),pData->station(),pData->type(),true,pData->state(),pData->connectedBus(),pData->label(),pData->context(),nPageId,1);
|
||||
for(auto &val:dataInfo.groupInfo)
|
||||
{
|
||||
componentInfo info = DataBase::GetInstance()->getComponentInfoByUuid(pData->uuid().toString());
|
||||
DataBase::GetInstance()->insertBus_stability(info.id,pro->getResistance(),pro->getAnchor_v(),pro->getUv_alarm(),pro->getOv_alarm(),pro->getAnchor_i(),pro->getUi_alarm(),pro->getOi_alarm(),1);
|
||||
}*/
|
||||
DataBase::GetInstance()->insertDynamicProperty(pData->uuid(),val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -592,14 +549,14 @@ QWidget* FixedPortsModel::getTopWidget()
|
|||
return dynamic_cast<QWidget*>(_widget);
|
||||
}
|
||||
|
||||
void FixedPortsModel::showModelDlg(const QString& sName,QUuid uuid)
|
||||
void FixedPortsModel::showModelDlg(const QString& sName,QUuid uuid,GraphicsBaseItem* pItem)
|
||||
{
|
||||
modelStateInfo stateInfo = _modelStateInfo[sName];
|
||||
ModelDataMap mapData = DataManager::instance().modelData();
|
||||
ItemPropertyDlg* pDlg = dynamic_cast<ItemPropertyDlg*>(stateInfo._PropertyDlg);
|
||||
if(pDlg)
|
||||
{
|
||||
pDlg->showDlg(mapData[sName],uuid);
|
||||
pDlg->showDlg(mapData[sName],uuid,pItem);
|
||||
}
|
||||
else
|
||||
qDebug()<<"showModelDlg err";
|
||||
|
|
@ -625,6 +582,7 @@ void FixedPortsModel::generatePropertyDlg(const QString& sModel)
|
|||
if(dlg)
|
||||
{
|
||||
dlg->loadGroupButton(info.groupInfo);
|
||||
_modelStateInfo[sModel]._PropertyDlg = dlg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ void ElectricSvgItemRect::paint(QPainter* painter, const QStyleOptionGraphicsIte
|
|||
}
|
||||
|
||||
|
||||
void ElectricSvgItemRect::updateByProperty()
|
||||
/*void ElectricSvgItemRect::updateByProperty()
|
||||
{
|
||||
|
||||
}
|
||||
}*/
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "graphicsItem/handleText.h"
|
||||
#include "graphicsItem/itemPort.h"
|
||||
#include "graphicsItem/electricConnectLineItem.h"
|
||||
#include "dataManager.h"
|
||||
#include <QGraphicsScene>
|
||||
#include <QJsonArray>
|
||||
|
||||
|
|
@ -330,3 +331,9 @@ VariableProperty::~VariableProperty()
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
modelDataInfo VariableProperty::getPropertyValue() const
|
||||
{
|
||||
ModelDataMap mapData = DataManager::instance().modelData();
|
||||
return mapData[sModelName];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
#include "itemPropertyDlg.h"
|
||||
#include "propertyContentDlg.h"
|
||||
#include "dataManager.h"
|
||||
#include "graphicsItem/graphicsBaseItem.h"
|
||||
#include "ui_itemPropertyDlg.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
ItemPropertyDlg::ItemPropertyDlg(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::itemPropertyDlg)
|
||||
,layout_(nullptr)
|
||||
,btnGroup_(nullptr)
|
||||
,_curItem(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||
|
|
@ -43,11 +46,25 @@ void ItemPropertyDlg::loadGroupButton(QMap<QString,groupStateInfo> map)
|
|||
onGroupSelected(info.groupName);
|
||||
});
|
||||
}
|
||||
layout_->addStretch();
|
||||
}
|
||||
|
||||
void ItemPropertyDlg::onOkClicked()
|
||||
{
|
||||
//todo:将属性页中的值读取到当前uuid对象
|
||||
if(_curItem)
|
||||
{
|
||||
if(_curItem->getProperty() == nullptr)
|
||||
{
|
||||
//todo:弹出输入框输入名称
|
||||
QMessageBox::information(NULL, QString("提示"), QString::fromWCharArray(L"对象未命名"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
curUuid_ = _curItem->getProperty()->uuid(); //使用数据uuid,数据唯一,item不唯一
|
||||
}
|
||||
}
|
||||
QMap<QString, QWidget*>::Iterator iter;
|
||||
for(iter = groupViews_.begin();iter != groupViews_.end();++iter)
|
||||
{
|
||||
|
|
@ -92,11 +109,12 @@ void ItemPropertyDlg::createGroupView(const QString& str)
|
|||
ui->stackedWidget->addWidget(contentDlg);
|
||||
}
|
||||
|
||||
void ItemPropertyDlg::showDlg(modelDataInfo dataInfo,QUuid uuid)
|
||||
void ItemPropertyDlg::showDlg(modelDataInfo dataInfo,QUuid uuid,GraphicsBaseItem* pItem)
|
||||
{
|
||||
groupValue_ = dataInfo.groupInfo;
|
||||
curUuid_ = uuid;
|
||||
_curModel = dataInfo.modelName;
|
||||
_curItem = pItem;
|
||||
QString firstName = groupInfo_.constBegin().key();
|
||||
onGroupSelected(firstName); //打开默认显示第一个属性组
|
||||
show();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ PropertyContentDlg::PropertyContentDlg(QWidget *parent)
|
|||
: QDialog(parent)
|
||||
,_layout(nullptr)
|
||||
{
|
||||
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||
setWindowFlags(Qt::Widget);
|
||||
//this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||
_layout = new QVBoxLayout(this);
|
||||
}
|
||||
|
||||
|
|
@ -23,11 +24,11 @@ void PropertyContentDlg::createGroupView(groupStateInfo infos)
|
|||
{
|
||||
QScrollArea* scrollArea = new QScrollArea(this);
|
||||
QWidget* content = new QWidget();
|
||||
QFormLayout* formLayout = createFormLayout();
|
||||
QFormLayout* formLayout = createFormLayout(content);
|
||||
|
||||
// 动态生成字段
|
||||
for(auto& info:infos.info) {
|
||||
QLabel* label = new QLabel(info.name);
|
||||
QLabel* label = new QLabel(info.name,this);
|
||||
QWidget* editor = createEditor(info);
|
||||
formLayout->addRow(label, editor);
|
||||
}
|
||||
|
|
@ -334,9 +335,9 @@ void PropertyContentDlg::setPropertyValue(QMap<QString,propertyStateInfo> map)
|
|||
}
|
||||
}
|
||||
|
||||
QFormLayout* PropertyContentDlg::createFormLayout()
|
||||
QFormLayout* PropertyContentDlg::createFormLayout(QWidget* parent)
|
||||
{
|
||||
QFormLayout* layout = new QFormLayout;
|
||||
QFormLayout* layout = new QFormLayout(parent);
|
||||
layout->setHorizontalSpacing(20); // 标签与控件间距
|
||||
layout->setVerticalSpacing(12); // 行间距
|
||||
layout->setLabelAlignment(Qt::AlignRight); // 标签右对齐
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ void BaseSelector::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, Design
|
|||
{
|
||||
QString modelName = item->getModelName(); //todo:additem时填写模型类型
|
||||
QUuid uuid = item->itemId();
|
||||
_model->showModelDlg(modelName,uuid);
|
||||
_model->showModelDlg(modelName,uuid,item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,12 +91,21 @@
|
|||
<string notr="true">background-color: rgb(219, 219, 219);</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_ok">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
|
|
@ -107,7 +116,7 @@
|
|||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
|
|
@ -120,6 +129,12 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_cancel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
|
|
@ -128,7 +143,7 @@
|
|||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ public:
|
|||
/*********************************************************************************/
|
||||
bool updateComponent(QUuid uuid,QString tag,QString name,QJsonObject context);
|
||||
bool insertComponent(QUuid uuid,QString modelName,QString nspath,QString tag,QString name,QString description,QString grid,QString zone,QString station,int type,bool inService,int state,QJsonObject connected_bus,QJsonObject label,QJsonObject context,int page_id,int op);
|
||||
bool insertDynamicProperty(QUuid uuid,groupStateValue groupValue);
|
||||
bool updateDynamicProperty(QUuid uuid,groupStateValue groupValue);
|
||||
componentInfo getComponentInfoByUuid(QString uuid);
|
||||
QList<componentInfo> getAllComponents();
|
||||
bool componentExist(QString uuid);
|
||||
|
|
@ -87,7 +89,7 @@ public:
|
|||
QMap<QString,int> getAllProjectModel(); //获取所有工程模<名称,图元类型>
|
||||
QMap<QString,propertyGroupState> getModelInfo(const QString&); //获取模型信息
|
||||
QMap<QString,projectManager> getProjectModelGroupInfo(const QString&); //获取指定工程模所有属性组信息<属性组名,属性信息>
|
||||
QMap<QUuid,PropertyValueInfo> selectGroupProperty(const QString& tableName,const QStringList& paramList); //返回属性组表中的信息
|
||||
QMap<QUuid,PropertyValueInfo> selectGroupProperty(const QString& tableName,QMap<QString,propertyStateInfo> mapPro); //返回属性组表中的信息
|
||||
private:
|
||||
QMap<int,attributeGroup> _attributeGroup; //属性组的组
|
||||
QMap<int,dataType> _dataType; //数据类型组
|
||||
|
|
|
|||
|
|
@ -294,6 +294,60 @@ bool DataBase::updateComponent(QUuid uuid,QString tag,QString name,QJsonObject c
|
|||
return false;
|
||||
}
|
||||
|
||||
bool DataBase::insertDynamicProperty(QUuid uuid,groupStateValue groupValue)
|
||||
{
|
||||
QString strPros;
|
||||
QString strPronouns;
|
||||
|
||||
QVariantList params;
|
||||
params.append(uuid);
|
||||
params.append(groupValue.groupName);
|
||||
|
||||
for(auto &pro:groupValue.mapInfo[uuid])
|
||||
{
|
||||
strPros += QString(",")+pro.name;
|
||||
strPronouns += QString(",?");
|
||||
params.append(pro.defaultValue);
|
||||
}
|
||||
QString strSQL = QString("INSERT INTO %1(global_uuid, attribute_group%2) VALUES (?, ?%3)").arg(groupValue.tableName,strPros,strPronouns);
|
||||
|
||||
try
|
||||
{
|
||||
executeSQL(strSQL,false,params);
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
LOG_ERROR("DB", QString("Insert dynamic table fail"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool DataBase::updateDynamicProperty(QUuid uuid,groupStateValue groupValue)
|
||||
{
|
||||
QStringList setClauses;
|
||||
|
||||
QVariantList params;
|
||||
for(auto &pro:groupValue.mapInfo[uuid])
|
||||
{
|
||||
setClauses.append(QString("%1 = ?").arg(pro.name));
|
||||
params.append(pro.defaultValue);
|
||||
}
|
||||
|
||||
QString strSQL = QString("UPDATE 1% SET %2 WHERE global_uuid = 3%").arg(groupValue.tableName).arg(setClauses.join(",")).arg(uuid.toString());
|
||||
|
||||
try
|
||||
{
|
||||
executeSQL(strSQL,false,params);
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
LOG_ERROR("DB", QString("Update table %1 fail").arg(groupValue.tableName));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool DataBase::insertPage(QString tag,QString name,int status,QJsonObject label,QJsonObject context,QString description,int op)
|
||||
{
|
||||
if(db.open())
|
||||
|
|
@ -574,7 +628,7 @@ QList<componentInfo> DataBase::getAllComponents()
|
|||
{
|
||||
QSqlQuery qry(db);
|
||||
|
||||
qry.prepare("SELECT id, global_uuid, tag, name, grid, zone, station, type, context, page_id, op FROM component");
|
||||
qry.prepare("SELECT id, global_uuid, model_name,tag, name, grid, zone, station, type, context, page_id, op FROM component");
|
||||
bool res = qry.exec();
|
||||
QString str = qry.lastQuery();
|
||||
if(!res)
|
||||
|
|
@ -589,16 +643,17 @@ QList<componentInfo> DataBase::getAllComponents()
|
|||
componentInfo inf;
|
||||
inf.id = qry.value(0).toInt();
|
||||
inf.uuid = QUuid(qry.value(1).toString());
|
||||
inf.tag = qry.value(2).toString();
|
||||
inf.name = qry.value(3).toString();
|
||||
inf.grid = qry.value(4).toString();
|
||||
inf.zone = qry.value(5).toString();
|
||||
inf.station = qry.value(6).toString();
|
||||
inf.type = qry.value(7).toInt();
|
||||
QString str = qry.value(8).toString();
|
||||
inf.modelName = qry.value(2).toString();
|
||||
inf.tag = qry.value(3).toString();
|
||||
inf.name = qry.value(4).toString();
|
||||
inf.grid = qry.value(5).toString();
|
||||
inf.zone = qry.value(6).toString();
|
||||
inf.station = qry.value(7).toString();
|
||||
inf.type = qry.value(8).toInt();
|
||||
QString str = qry.value(9).toString();
|
||||
inf.context = QstringToJson(str);
|
||||
inf.page_id = qry.value(9).toInt();
|
||||
inf.op = qry.value(10).toInt();
|
||||
inf.page_id = qry.value(10).toInt();
|
||||
inf.op = qry.value(11).toInt();
|
||||
lst.push_back(inf);
|
||||
}
|
||||
qry.clear();
|
||||
|
|
@ -1406,8 +1461,13 @@ QMap<QString,projectManager> DataBase::getProjectModelGroupInfo(const QString& s
|
|||
}
|
||||
}
|
||||
|
||||
QMap<QUuid,PropertyValueInfo> DataBase::selectGroupProperty(const QString& tableName,const QStringList& paramList)
|
||||
QMap<QUuid,PropertyValueInfo> DataBase::selectGroupProperty(const QString& tableName,QMap<QString,propertyStateInfo> mapPro)
|
||||
{
|
||||
QStringList paramList;
|
||||
for(auto &pro:mapPro)
|
||||
{
|
||||
paramList.append(pro.name);
|
||||
}
|
||||
QString strSQL = QString("SELECT %1 FROM %2").arg(paramList.join(", ")).arg(tableName);
|
||||
QMap<QUuid,PropertyValueInfo> map;
|
||||
PropertyValueInfo info;
|
||||
|
|
@ -1418,16 +1478,18 @@ QMap<QUuid,PropertyValueInfo> DataBase::selectGroupProperty(const QString& table
|
|||
while (query.next())
|
||||
{
|
||||
QUuid uuid;
|
||||
for(auto ¶m:paramList)
|
||||
for(auto &proVal:mapPro)
|
||||
{
|
||||
propertyStateInfo pro;
|
||||
if(param == "global_uuid")
|
||||
if(proVal.name == "global_uuid") //剔除uuid所属的临时对象
|
||||
{
|
||||
uuid = QUuid(query.value(param).toString());
|
||||
uuid = QUuid(query.value(proVal.name).toString());
|
||||
continue;
|
||||
}
|
||||
pro.defaultValue = query.value(param).toString();
|
||||
info.insert(param,pro);
|
||||
pro.name = proVal.name;
|
||||
pro.type = proVal.type;
|
||||
pro.defaultValue = query.value(proVal.name );
|
||||
info.insert(proVal.name ,pro);
|
||||
}
|
||||
map.insert(uuid,info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,13 +30,14 @@ void DataManager::initialModelState()
|
|||
{
|
||||
modelStateInfo modelInfo;
|
||||
modelInfo.modelType = iter.value(); //模型类型
|
||||
modelInfo.modelName = iter.key();
|
||||
|
||||
groupStateInfo groupInfo;
|
||||
QMap<QString,propertyGroupState> mapState = DataBase::GetInstance()->getModelInfo(iter.key());
|
||||
|
||||
QMap<QString,propertyGroupState>::Iterator it;
|
||||
for(it = mapState.begin();it != mapState.end();++it) //遍历模型属性组
|
||||
{
|
||||
groupStateInfo groupInfo;
|
||||
groupInfo.groupName = it.key();
|
||||
groupInfo.tableName = it->tableName;
|
||||
QJsonArray nodesJsonArray = it->propertyState["checkState"].toArray();
|
||||
|
|
@ -78,6 +79,7 @@ void DataManager::initialModelData()
|
|||
{
|
||||
modelDataInfo modelInfo;
|
||||
modelInfo.modelType = iter.value(); //模型类型
|
||||
modelInfo.modelName = iter.key();
|
||||
|
||||
QMap<QString,propertyGroupState> mapState = DataBase::GetInstance()->getModelInfo(iter.key());
|
||||
|
||||
|
|
@ -86,10 +88,10 @@ void DataManager::initialModelData()
|
|||
{
|
||||
groupStateValue groupValue;
|
||||
groupValue.groupName = it.key();
|
||||
groupValue.tableName = it->tableName;
|
||||
QJsonArray nodesJsonArray = it->propertyState["checkState"].toArray();
|
||||
|
||||
QStringList lstParam; //需检索的属性组中属性名列表
|
||||
|
||||
QMap<QString,propertyStateInfo> mapPro;
|
||||
for (QJsonValueRef nodeJson : nodesJsonArray) //每个属性的状态信息
|
||||
{
|
||||
propertyStateInfo propertyInfo;
|
||||
|
|
@ -100,13 +102,18 @@ void DataManager::initialModelData()
|
|||
QString dataType = node["type"].toString();
|
||||
QVariant defaultValue = node["defaultValue"].toVariant();
|
||||
|
||||
propertyInfo.name = propertyName;
|
||||
propertyInfo.type = dataType;
|
||||
if(nState)
|
||||
{
|
||||
lstParam.append(propertyName);
|
||||
mapPro.insert(propertyName,propertyInfo);
|
||||
}
|
||||
}
|
||||
lstParam.append("global_uuid"); //全局id未添加到属性状态中,手动选择
|
||||
groupValue.mapInfo = DataBase::GetInstance()->selectGroupProperty(it->tableName,lstParam); //返回表中属性值
|
||||
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);
|
||||
}
|
||||
|
|
@ -117,7 +124,11 @@ void DataManager::initialModelData()
|
|||
|
||||
void DataManager::updateModelData(const QString& sModel,QUuid uuid,const QString& sGroup,QMap<QString,propertyStateInfo> mapPro)
|
||||
{
|
||||
_modleDataInfo[sModel].groupInfo[sGroup].mapInfo[uuid] = mapPro; //暂用设定值直接替换旧属性,待测试
|
||||
if(_modleDataInfo[sModel].groupInfo[sGroup].mapInfo.contains(uuid))
|
||||
_modleDataInfo[sModel].groupInfo[sGroup].mapInfo[uuid] = mapPro; //暂用设定值直接替换旧属性,待测试
|
||||
else{ //新增
|
||||
_modleDataInfo[sModel].groupInfo[sGroup].mapInfo.insert(uuid,mapPro);
|
||||
}
|
||||
}
|
||||
|
||||
ModleStateMap& DataManager::modelState()
|
||||
|
|
|
|||
Loading…
Reference in New Issue