fix bug
This commit is contained in:
parent
54694f6425
commit
5b2273f021
|
|
@ -382,20 +382,41 @@ struct gridInfo //grid
|
||||||
//===================组态编辑器使用================
|
//===================组态编辑器使用================
|
||||||
struct DiagramEditorWizardInfo //组态编辑向导信息
|
struct DiagramEditorWizardInfo //组态编辑向导信息
|
||||||
{
|
{
|
||||||
int nIndex = 0;
|
/*int nIndex = 0;
|
||||||
double dVoltage = 0;
|
double dVoltage = 0;
|
||||||
int nLineType = 1; //1单母线,2双母线
|
int nLineType = 1; //1单母线,2双母线
|
||||||
QMap<bool,int> mapDivide; //母线划分数,false为1母线,true为2母
|
QMap<bool,int> mapDivide; //母线划分数,false为1母线,true为2母
|
||||||
|
int connectType = 0;*/ //接线方式,1为分段连接
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DiagramEditorWizardBusInfo //组态编辑母线信息
|
||||||
|
{
|
||||||
|
int nIndex = 0;
|
||||||
|
double dVoltage = 0; //电压等级
|
||||||
|
int nLineType = 1; //1单母线,2双母线
|
||||||
|
int nNum1 = 0; //1母
|
||||||
|
int nNum2 = 0; //2母
|
||||||
int connectType = 0; //接线方式,1为分段连接
|
int connectType = 0; //接线方式,1为分段连接
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DiagramEditorBusInfo //组态编辑母线信息
|
enum class BayType //间隔类型
|
||||||
{
|
{
|
||||||
int nIndex = 0;
|
busSectionBay = 0, //分段
|
||||||
double dVoltage = 0;
|
busCouplerBay, //母联
|
||||||
int nLineType = 1; //1单母线,2双母线
|
ptBay, //pt
|
||||||
QMap<bool,int> mapDivide; //母线划分数,false为1母线,true为2母
|
incomingBay, //进线
|
||||||
int connectType = 0; //接线方式,1为分段连接
|
outcomingBay, //出线
|
||||||
|
compensationBay, //无功补偿
|
||||||
|
bypassBay, //旁路
|
||||||
|
mainTransformerBay //主变
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct DiagramEditorWizardBayInfo //组态间隔信息
|
||||||
|
{
|
||||||
|
QString sName;
|
||||||
|
BayType nType;
|
||||||
|
QList<QString> lstBindObj; //连接的对象
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DiagramEditorStructType
|
enum class DiagramEditorStructType
|
||||||
|
|
@ -404,6 +425,28 @@ enum class DiagramEditorStructType
|
||||||
rowData //母线对应的一行数据
|
rowData //母线对应的一行数据
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DiagramEditorConnectType //组态编辑连接信息
|
||||||
|
{
|
||||||
|
QString sName;
|
||||||
|
int nType = 0; //1母线,2间隔
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DiagramEditorBriefConnect //组态编辑时连接信息
|
||||||
|
{
|
||||||
|
DiagramEditorConnectType con1;
|
||||||
|
DiagramEditorConnectType con2;
|
||||||
|
|
||||||
|
bool operator==(const DiagramEditorBriefConnect& obj)
|
||||||
|
{
|
||||||
|
if(this == &obj)
|
||||||
|
return false;
|
||||||
|
if((con1.sName == obj.con1.sName && con2.sName == obj.con2.sName)||(con1.sName == obj.con2.sName && con2.sName == obj.con1.sName))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//==================组态图使用=====================
|
//==================组态图使用=====================
|
||||||
enum HandleType
|
enum HandleType
|
||||||
{
|
{
|
||||||
|
|
@ -688,6 +731,7 @@ struct bayInfo
|
||||||
QJsonObject dynSense;
|
QJsonObject dynSense;
|
||||||
QJsonObject instruct;
|
QJsonObject instruct;
|
||||||
QJsonObject etc;
|
QJsonObject etc;
|
||||||
|
QJsonObject context;
|
||||||
QList<QUuid> components;
|
QList<QUuid> components;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ void DiagramEditorWizard::generateBayPage()
|
||||||
sVoltage = QString::number(iter->dVoltage)+"kV";
|
sVoltage = QString::number(iter->dVoltage)+"kV";
|
||||||
|
|
||||||
if(iter->nLineType == 1){ //单母
|
if(iter->nLineType == 1){ //单母
|
||||||
int nDivide = iter->mapDivide.value(0);
|
int nDivide = iter->nNum1;
|
||||||
|
|
||||||
for(int i = 0;i < nDivide;++i){
|
for(int i = 0;i < nDivide;++i){
|
||||||
QString sDivPre; //分段前缀
|
QString sDivPre; //分段前缀
|
||||||
|
|
@ -103,8 +103,8 @@ void DiagramEditorWizard::generateBayPage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{ //双母
|
else{ //双母
|
||||||
int nDivide1 = iter->mapDivide.value(0); // Ⅰ母
|
int nDivide1 = iter->nNum1; // Ⅰ母
|
||||||
int nDivide2 = iter->mapDivide.value(1); // Ⅱ母
|
int nDivide2 = iter->nNum2; // Ⅱ母
|
||||||
|
|
||||||
if(nDivide1 == nDivide2){ //双母线划分相同
|
if(nDivide1 == nDivide2){ //双母线划分相同
|
||||||
for(int i = 0;i < nDivide1;++i){
|
for(int i = 0;i < nDivide1;++i){
|
||||||
|
|
@ -302,15 +302,14 @@ void DiagramEditorWizard::onDelegateFinishEdit(const QModelIndex &index, const Q
|
||||||
divideItem->setData(Qt::UserRole,0);
|
divideItem->setData(Qt::UserRole,0);
|
||||||
}
|
}
|
||||||
else if(col == 3){
|
else if(col == 3){
|
||||||
_mapBus[row].mapDivide.clear();
|
|
||||||
QStringList lst = value.split(",");
|
QStringList lst = value.split(",");
|
||||||
if(lst.size() > 1) //双母
|
if(lst.size() > 1) //双母
|
||||||
{
|
{
|
||||||
_mapBus[row].mapDivide[0] = lst[0].toInt();
|
_mapBus[row].nNum1 = lst[0].toInt();
|
||||||
_mapBus[row].mapDivide[1] = lst[1].toInt();
|
_mapBus[row].nNum2= lst[1].toInt();
|
||||||
}
|
}
|
||||||
else{ //单母
|
else{ //单母
|
||||||
_mapBus[row].mapDivide[0] = lst[0].toInt();
|
_mapBus[row].nNum1 = lst[0].toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(col == 4){
|
else if(col == 4){
|
||||||
|
|
@ -347,7 +346,7 @@ void DiagramEditorWizard::onBusDeleteClicked()
|
||||||
QModelIndex indexName = index.sibling(index.row(),0);
|
QModelIndex indexName = index.sibling(index.row(),0);
|
||||||
int nIndex = indexName.data(Qt::UserRole).toInt();
|
int nIndex = indexName.data(Qt::UserRole).toInt();
|
||||||
if(_mapBus.contains(nIndex)){
|
if(_mapBus.contains(nIndex)){
|
||||||
DiagramEditorWizardBusInfo info = _mapBus.take(nIndex);
|
_mapBus.remove(nIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentRow = ui->tableWidget_bus->currentRow();
|
int currentRow = ui->tableWidget_bus->currentRow();
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,8 @@ public:
|
||||||
QJsonObject getPageContextByName(QString name);
|
QJsonObject getPageContextByName(QString name);
|
||||||
QList<pageInfo> getAllPage();
|
QList<pageInfo> getAllPage();
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
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 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,QJsonObject context);
|
||||||
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);
|
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,QJsonObject context);
|
||||||
bayInfo getBay(QUuid uuid);
|
bayInfo getBay(QUuid uuid);
|
||||||
QList<bayInfo> getAllBay();
|
QList<bayInfo> getAllBay();
|
||||||
bool ifBayExist(QUuid uuid);
|
bool ifBayExist(QUuid uuid);
|
||||||
|
|
|
||||||
|
|
@ -1059,7 +1059,7 @@ bool DataBase::deleteComponentById(int id)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
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,
|
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,
|
QString station,QJsonObject business,QJsonObject fromUuid,QJsonObject toUuid,QJsonObject protect,QJsonObject faultRec,QJsonObject status,QJsonObject dynSense,
|
||||||
QJsonObject instruct,QJsonObject etc,QList<QUuid> components)
|
QJsonObject instruct,QJsonObject etc,QList<QUuid> components,QJsonObject context)
|
||||||
{
|
{
|
||||||
QJsonDocument businessDoc(business);
|
QJsonDocument businessDoc(business);
|
||||||
QString strBusiness = businessDoc.toJson(QJsonDocument::Compact);
|
QString strBusiness = businessDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
@ -1088,7 +1088,10 @@ bool DataBase::insertBay(QUuid uuid,QString name,QString type,double unom,double
|
||||||
QJsonDocument etcDoc(etc);
|
QJsonDocument etcDoc(etc);
|
||||||
QString strEtc = etcDoc.toJson(QJsonDocument::Compact);
|
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
QJsonDocument contextDoc(etc);
|
||||||
|
QString strContext = contextDoc.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, context) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
QStringList uuidStrings;
|
QStringList uuidStrings;
|
||||||
for (const QUuid &uuid : components) {
|
for (const QUuid &uuid : components) {
|
||||||
|
|
@ -1120,6 +1123,7 @@ bool DataBase::insertBay(QUuid uuid,QString name,QString type,double unom,double
|
||||||
params.append(strInstruct);
|
params.append(strInstruct);
|
||||||
params.append(strEtc);
|
params.append(strEtc);
|
||||||
params.append(arrayUuid);
|
params.append(arrayUuid);
|
||||||
|
params.append(strContext);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -1135,7 +1139,7 @@ bool DataBase::insertBay(QUuid uuid,QString name,QString type,double unom,double
|
||||||
|
|
||||||
bool DataBase::updateBay(QUuid uuid,QString name,double unom,double fla,double capacity,QString description,bool inService,int nState,QJsonObject business,
|
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 fromUuid,QJsonObject toUuid,QJsonObject protect,QJsonObject faultRec,QJsonObject status,QJsonObject dynSense,QJsonObject instruct,
|
||||||
QJsonObject etc,QList<QUuid> components)
|
QJsonObject etc,QList<QUuid> components,QJsonObject context)
|
||||||
{
|
{
|
||||||
QJsonDocument businessDoc(business);
|
QJsonDocument businessDoc(business);
|
||||||
QString strBusiness = businessDoc.toJson(QJsonDocument::Compact);
|
QString strBusiness = businessDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
@ -1164,6 +1168,9 @@ bool DataBase::updateBay(QUuid uuid,QString name,double unom,double fla,double c
|
||||||
QJsonDocument etcDoc(etc);
|
QJsonDocument etcDoc(etc);
|
||||||
QString strEtc = etcDoc.toJson(QJsonDocument::Compact);
|
QString strEtc = etcDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
QJsonDocument contextDoc(etc);
|
||||||
|
QString strContext = contextDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
QStringList uuidStrings;
|
QStringList uuidStrings;
|
||||||
for (const QUuid &uuid : components) {
|
for (const QUuid &uuid : components) {
|
||||||
// 使用WithoutBraces确保无花括号,符合PG数组元素格式
|
// 使用WithoutBraces确保无花括号,符合PG数组元素格式
|
||||||
|
|
@ -1171,7 +1178,7 @@ bool DataBase::updateBay(QUuid uuid,QString name,double unom,double fla,double c
|
||||||
}
|
}
|
||||||
QString arrayUuid = "{" + uuidStrings.join(",") + "}";
|
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 = ?";
|
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 = ?,context = ? WHERE bay_uuid = ?";
|
||||||
QVariantList params;
|
QVariantList params;
|
||||||
params.append(name);
|
params.append(name);
|
||||||
params.append(unom);
|
params.append(unom);
|
||||||
|
|
@ -1190,6 +1197,7 @@ bool DataBase::updateBay(QUuid uuid,QString name,double unom,double fla,double c
|
||||||
params.append(strInstruct);
|
params.append(strInstruct);
|
||||||
params.append(strEtc);
|
params.append(strEtc);
|
||||||
params.append(arrayUuid);
|
params.append(arrayUuid);
|
||||||
|
params.append(strContext);
|
||||||
params.append(uuid);
|
params.append(uuid);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -1207,7 +1215,7 @@ bool DataBase::updateBay(QUuid uuid,QString name,double unom,double fla,double c
|
||||||
bayInfo DataBase::getBay(QUuid uuid)
|
bayInfo DataBase::getBay(QUuid uuid)
|
||||||
{
|
{
|
||||||
bayInfo info;
|
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 = ?";
|
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, context FROM bay WHERE bay_uuid = ?";
|
||||||
QVariantList params;
|
QVariantList params;
|
||||||
params.append(uuid);
|
params.append(uuid);
|
||||||
|
|
||||||
|
|
@ -1248,6 +1256,8 @@ bayInfo DataBase::getBay(QUuid uuid)
|
||||||
info.etc = QstringToJson(strEtc);
|
info.etc = QstringToJson(strEtc);
|
||||||
QString rawData = query.value(21).toString();
|
QString rawData = query.value(21).toString();
|
||||||
info.components = parseUuidArray(rawData);
|
info.components = parseUuidArray(rawData);
|
||||||
|
QString strContext= query.value(22).toString();
|
||||||
|
info.context = QstringToJson(strContext);
|
||||||
}
|
}
|
||||||
query.clear();
|
query.clear();
|
||||||
return info;
|
return info;
|
||||||
|
|
@ -1261,7 +1271,7 @@ bayInfo DataBase::getBay(QUuid uuid)
|
||||||
QList<bayInfo> DataBase::getAllBay()
|
QList<bayInfo> DataBase::getAllBay()
|
||||||
{
|
{
|
||||||
QList<bayInfo> lstInfo;
|
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";
|
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, context FROM bay";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -1301,6 +1311,8 @@ QList<bayInfo> DataBase::getAllBay()
|
||||||
info.etc = QstringToJson(strEtc);
|
info.etc = QstringToJson(strEtc);
|
||||||
QString rawData = query.value(21).toString();
|
QString rawData = query.value(21).toString();
|
||||||
info.components = parseUuidArray(rawData);
|
info.components = parseUuidArray(rawData);
|
||||||
|
QString strContext= query.value(22).toString();
|
||||||
|
info.context = QstringToJson(strContext);
|
||||||
lstInfo.append(info);
|
lstInfo.append(info);
|
||||||
}
|
}
|
||||||
query.clear();
|
query.clear();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue