[ref]同步711 新加的插件
This commit is contained in:
parent
343e7a8d41
commit
d198d1cdc6
121
product/src/gui/plugin/AlarmWidget_pad/AlarmWidget_pad.pro
Normal file
121
product/src/gui/plugin/AlarmWidget_pad/AlarmWidget_pad.pro
Normal file
@ -0,0 +1,121 @@
|
||||
QT += core sql xml multimedia webenginewidgets texttospeech
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TEMPLATE = lib
|
||||
TARGET = AlarmWidget_pad
|
||||
|
||||
CONFIG += plugin
|
||||
|
||||
|
||||
HEADERS = \
|
||||
CAlarmBaseData.h \
|
||||
CAlarmItemModel.h \
|
||||
CAlarmShiledDialog.h \
|
||||
CAlarmView.h \
|
||||
CAlarmDelegate.h \
|
||||
CAlarmForm.h \
|
||||
CAlarmFilterDialog.h \
|
||||
CAlarmWidget.h \
|
||||
CAlarmDataCollect.h \
|
||||
CAlarmMsgInfo.h \
|
||||
CAlarmPlugin.h \
|
||||
CAlarmMsgManage.h \
|
||||
CAlarmPluginWidget.h \
|
||||
CAlarmMediaPlayer.h \
|
||||
CTableViewPrinter.h \
|
||||
CAlarmInhibitDialog.h \
|
||||
CAlarmDeviceTreeItem.h \
|
||||
CAlarmDeviceTreeModel.h \
|
||||
CAlarmDeviceTreeView.h \
|
||||
CAlarmCommon.h \
|
||||
CMyListWidget.h \
|
||||
CMyCalendar.h \
|
||||
CMyCheckBox.h \
|
||||
CAiAlarmTreeView.h \
|
||||
CAiAlarmMsgInfo.h \
|
||||
CAiAlarmDataCollect.h \
|
||||
CAiAlarmTreeItem.h \
|
||||
CAiAlarmTreeModel.h \
|
||||
CAiAlarmDelegate.h \
|
||||
CDisposalPlanDialog.h \
|
||||
CTreeViewPrinter.h \
|
||||
CPdfPrinter.h \
|
||||
CAlarmTaskMngDlg.h \
|
||||
CAlarmSetDlg.h \
|
||||
CAlarmColorInfo.h \
|
||||
CAlarmSetMng.h \
|
||||
CAlarmColorWidget.h \
|
||||
CAccidentReviewDialog.h \
|
||||
../../../../../platform/src/include/service/operate_server_api/JsonMessageStruct.h \
|
||||
../../../../../platform/src/include/service/operate_server_api/JsonOptCommand.h
|
||||
|
||||
SOURCES = \
|
||||
CAlarmBaseData.cpp \
|
||||
CAlarmItemModel.cpp \
|
||||
CAlarmShiledDialog.cpp \
|
||||
CAlarmView.cpp \
|
||||
CAlarmDelegate.cpp \
|
||||
CAlarmForm.cpp \
|
||||
CAlarmFilterDialog.cpp \
|
||||
CAlarmWidget.cpp \
|
||||
CAlarmDataCollect.cpp \
|
||||
CAlarmMsgInfo.cpp \
|
||||
CAlarmPlugin.cpp \
|
||||
CAlarmMsgManage.cpp \
|
||||
CAlarmPluginWidget.cpp \
|
||||
CAlarmMediaPlayer.cpp \
|
||||
CTableViewPrinter.cpp \
|
||||
CAlarmInhibitDialog.cpp \
|
||||
CAlarmDeviceTreeModel.cpp \
|
||||
CAlarmDeviceTreeItem.cpp \
|
||||
CAlarmDeviceTreeView.cpp \
|
||||
CMyListWidget.cpp \
|
||||
CMyCalendar.cpp \
|
||||
CMyCheckBox.cpp \
|
||||
CAiAlarmTreeView.cpp \
|
||||
CAiAlarmMsgInfo.cpp \
|
||||
CAiAlarmDataCollect.cpp \
|
||||
CAiAlarmTreeItem.cpp \
|
||||
CAiAlarmTreeModel.cpp \
|
||||
CAiAlarmDelegate.cpp \
|
||||
CDisposalPlanDialog.cpp \
|
||||
CTreeViewPrinter.cpp \
|
||||
CPdfPrinter.cpp \
|
||||
CAlarmTaskMngDlg.cpp \
|
||||
CAlarmSetDlg.cpp \
|
||||
CAlarmColorInfo.cpp \
|
||||
CAlarmSetMng.cpp \
|
||||
CAlarmColorWidget.cpp \
|
||||
CAccidentReviewDialog.cpp \
|
||||
../../../../../platform/src/include/service/operate_server_api/JsonOptCommand.cpp
|
||||
|
||||
FORMS += \
|
||||
CAlarmFilterDialog.ui \
|
||||
CAlarmForm.ui \
|
||||
CAlarmInhibitDialog.ui \
|
||||
CAlarmShiledDialog.ui \
|
||||
CMyCalendar.ui \
|
||||
CDisposalPlanDialog.ui \
|
||||
CAlarmTaskMngDlg.ui \
|
||||
CAlarmSetDlg.ui \
|
||||
CAlarmColorWidget.ui
|
||||
|
||||
|
||||
LIBS += -llog4cplus -lboost_system -lboost_filesystem -lprotobuf -lpub_logger_api -ldb_base_api -ldb_api_ex -lpub_utility_api -lrdb_api -lrdb_net_api -lperm_mng_api -lpub_sysinfo_api
|
||||
LIBS += -lnet_msg_bus_api -lalarm_server_api -lintelli_alm_api -lpub_excel -lidong_srv_api
|
||||
LIBS += -ldb_his_mng_api
|
||||
|
||||
win32{
|
||||
# CAlarmMediaPlayer.cpp 检测声卡的代码使用
|
||||
LIBS += -lole32
|
||||
}
|
||||
|
||||
include($$PWD/../../../idl_files/idl_files.pri)
|
||||
|
||||
COMMON_PRI=$$PWD/../../../common.pri
|
||||
exists($$COMMON_PRI) {
|
||||
include($$COMMON_PRI)
|
||||
}else {
|
||||
error("FATAL error: can not find common.pri")
|
||||
}
|
||||
289
product/src/gui/plugin/AlarmWidget_pad/CAccidentReviewDialog.cpp
Normal file
289
product/src/gui/plugin/AlarmWidget_pad/CAccidentReviewDialog.cpp
Normal file
@ -0,0 +1,289 @@
|
||||
#include "CAccidentReviewDialog.h"
|
||||
#include "public/pub_utility_api/FileUtil.h"
|
||||
#include "public/pub_logger_api/logger.h"
|
||||
#include <QTreeWidget>
|
||||
#include <QPushButton>
|
||||
#include <QGridLayout>
|
||||
#include <QSpacerItem>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
|
||||
CAccidentReviewDialog::CAccidentReviewDialog(const QString &path, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
resize(350,450);
|
||||
getFilterNames(path);
|
||||
initView();
|
||||
initTree();
|
||||
}
|
||||
|
||||
CAccidentReviewDialog::~CAccidentReviewDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString CAccidentReviewDialog::getCurrentGraph()
|
||||
{
|
||||
if(m_treeWidget->currentItem())
|
||||
{
|
||||
return m_treeWidget->currentItem()->data(0, Qt::UserRole).toString();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
void CAccidentReviewDialog::initView()
|
||||
{
|
||||
setWindowTitle(tr("事故追忆"));
|
||||
m_treeWidget = new QTreeWidget(this);
|
||||
m_treeWidget->headerItem()->setHidden(true);
|
||||
|
||||
QSpacerItem * spacer = new QSpacerItem(10, 0, QSizePolicy::Preferred);
|
||||
m_confirmBtn = new QPushButton(tr("确认"), this);
|
||||
m_cancelBtn = new QPushButton(tr("取消"), this);
|
||||
connect(m_confirmBtn, &QPushButton::clicked, this, &CAccidentReviewDialog::slotConfirm);
|
||||
connect(m_cancelBtn, &QPushButton::clicked, this, &CAccidentReviewDialog::slotCancel);
|
||||
|
||||
QGridLayout * layout = new QGridLayout();
|
||||
layout->addWidget(m_treeWidget, 0, 0, 1, 3);
|
||||
layout->addItem(spacer, 1, 0);
|
||||
layout->addWidget(m_confirmBtn, 1, 1);
|
||||
layout->addWidget(m_cancelBtn, 1, 2);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void CAccidentReviewDialog::initTree()
|
||||
{
|
||||
QMap<int, QList<QPair<int, ST_NODE>>> m_mapNav;
|
||||
readNavJson(QString::fromStdString(iot_public::CFileUtil::getCurModuleDir())
|
||||
+ QString("../../data/model/NavigationWidget.json"), m_mapNav);
|
||||
QList<QPair<int, ST_NODE>> nodeList = m_mapNav.value(-1);
|
||||
for(int nIndex=0; nIndex<nodeList.length(); nIndex++)
|
||||
{
|
||||
QTreeWidgetItem *item = getAddLevelItem(nodeList[nIndex].second);
|
||||
if(item == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
m_treeWidget->addTopLevelItem(item);
|
||||
|
||||
addChildLevelItem(item, nodeList[nIndex], m_mapNav);
|
||||
}
|
||||
treeFilter();
|
||||
m_treeWidget->expandAll();
|
||||
}
|
||||
|
||||
void CAccidentReviewDialog::getFilterNames(const QString &path)
|
||||
{
|
||||
QString filePath = QString::fromStdString(iot_public::CFileUtil::getCurModuleDir())
|
||||
+ QString("../../data/pic/");
|
||||
m_fileNameList = getAllFile(filePath, filePath, path);
|
||||
}
|
||||
|
||||
QStringList CAccidentReviewDialog::getAllFile(const QString &path, const QString &relativePath, const QString &filter)
|
||||
{
|
||||
QDir dir(path);
|
||||
QDir relativeDir(relativePath);
|
||||
QStringList allFile;
|
||||
|
||||
QString fileName;
|
||||
QFileInfoList fileList = dir.entryInfoList(QDir::Files | QDir::NoSymLinks);
|
||||
for(QFileInfo &file : fileList)
|
||||
{
|
||||
fileName = relativeDir.relativeFilePath(file.filePath());
|
||||
if(fileName.contains(filter))
|
||||
{
|
||||
allFile.append(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
QFileInfoList folderList = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for(QFileInfo &folder : folderList)
|
||||
{
|
||||
allFile.append(getAllFile(folder.absoluteFilePath(), relativePath, filter));
|
||||
}
|
||||
|
||||
return allFile;
|
||||
}
|
||||
|
||||
void CAccidentReviewDialog::treeFilter()
|
||||
{
|
||||
bool topShow,childShow,leafShow;
|
||||
int nTopCount = m_treeWidget->topLevelItemCount();
|
||||
for(int nTopIndex(0); nTopIndex<nTopCount; nTopIndex++)
|
||||
{
|
||||
QTreeWidgetItem * topItem = m_treeWidget->topLevelItem(nTopIndex);
|
||||
topShow = m_fileNameList.contains(topItem->data(0, Qt::UserRole).toString());
|
||||
|
||||
int nChildCount = topItem->childCount();
|
||||
for(int nChildIndex(0); nChildIndex<nChildCount; nChildIndex++)
|
||||
{
|
||||
QTreeWidgetItem * childItem = topItem->child(nChildIndex);
|
||||
childShow = m_fileNameList.contains(childItem->data(0, Qt::UserRole).toString());
|
||||
|
||||
int nLeafCount = childItem->childCount();
|
||||
for(int nLeafIndex(0); nLeafIndex<nLeafCount; nLeafIndex++)
|
||||
{
|
||||
QTreeWidgetItem * leafItem = childItem->child(nLeafIndex);
|
||||
leafShow = m_fileNameList.contains(leafItem->data(0, Qt::UserRole).toString());
|
||||
leafItem->setHidden(!leafShow);
|
||||
if(leafShow)
|
||||
{
|
||||
childShow = true;
|
||||
}
|
||||
}
|
||||
childItem->setHidden(!childShow);
|
||||
if(childShow)
|
||||
{
|
||||
topShow = true;
|
||||
}
|
||||
}
|
||||
topItem->setHidden(!topShow);
|
||||
}
|
||||
}
|
||||
|
||||
void CAccidentReviewDialog::slotConfirm()
|
||||
{
|
||||
if(m_treeWidget->currentItem() == NULL)
|
||||
{
|
||||
QMessageBox::information(this, tr("提示"), tr("请选择一张画面!"), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
QString data = m_treeWidget->currentItem()->data(0, Qt::UserRole).toString();
|
||||
if(data.isEmpty() || !m_fileNameList.contains(data))
|
||||
{
|
||||
QMessageBox::information(this, tr("提示"), tr("请选择其他画面!"), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
accept();
|
||||
}
|
||||
|
||||
void CAccidentReviewDialog::slotCancel()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
void CAccidentReviewDialog::addChildLevelItem(QTreeWidgetItem *item, const QPair<int, ST_NODE> &node,
|
||||
const QMap<int, QList<QPair<int, ST_NODE> > > &navMap)
|
||||
{
|
||||
const QList<QPair<int, ST_NODE> > childList = navMap.value(node.first);
|
||||
for(int nIndex=0; nIndex<childList.length(); nIndex++)
|
||||
{
|
||||
QTreeWidgetItem *childItem = getAddLevelItem(childList[nIndex].second);
|
||||
if(childItem == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
item->addChild(childItem);
|
||||
|
||||
addChildLevelItem(childItem, childList[nIndex], navMap);
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem *CAccidentReviewDialog::getAddLevelItem(const ST_NODE &st_node)
|
||||
{
|
||||
if(st_node.used == Disable)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QTreeWidgetItem * childItem = new QTreeWidgetItem();
|
||||
childItem->setData(0, Qt::DisplayRole, st_node.name);
|
||||
childItem->setData(0, Qt::UserRole, st_node.data);
|
||||
return childItem;
|
||||
}
|
||||
|
||||
void CAccidentReviewDialog::readNavJson(const QString &path, QMap<int, QList<QPair<int, ST_NODE> > > &map)
|
||||
{
|
||||
QFile file(path);
|
||||
QByteArray readJson;
|
||||
if(file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
readJson = file.readAll();
|
||||
file.close();
|
||||
}
|
||||
QJsonParseError readError;
|
||||
QJsonDocument readJsonResponse = QJsonDocument::fromJson(readJson, &readError);
|
||||
if(readError.error != QJsonParseError::NoError)
|
||||
{
|
||||
LOGERROR("CJsonReader error: %d, string: %s", readError.error, readError.errorString().toStdString().c_str());
|
||||
return;
|
||||
}
|
||||
QJsonObject root = readJsonResponse.object();
|
||||
if(root.contains("items"))
|
||||
{
|
||||
QJsonArray itemArray = root.value("items").toArray();
|
||||
int nItemNumber = 0;
|
||||
for(int nIndex(0); nIndex< itemArray.size(); nIndex++)
|
||||
{
|
||||
ST_NODE st_Node_Top;
|
||||
QJsonObject topLevelObject = itemArray[nIndex].toObject();
|
||||
makeStButton(st_Node_Top, topLevelObject);
|
||||
QPair<int, ST_NODE> topMap;
|
||||
int nTopNumber = nItemNumber;
|
||||
topMap.first = nItemNumber++;
|
||||
topMap.second = st_Node_Top;
|
||||
|
||||
QJsonArray childArray = topLevelObject.value("items").toArray();
|
||||
for(int nChildIndex(0); nChildIndex< childArray.size(); nChildIndex++)
|
||||
{
|
||||
ST_NODE st_Node_Child;
|
||||
QJsonObject childLevelObject = childArray[nChildIndex].toObject();
|
||||
makeStButton(st_Node_Child, childLevelObject);
|
||||
QPair<int, ST_NODE> childMap;
|
||||
int nChildNumber = nItemNumber;
|
||||
childMap.first = nItemNumber++;
|
||||
childMap.second = st_Node_Child;
|
||||
|
||||
QJsonArray leafArray = childLevelObject.value("items").toArray();
|
||||
for(int nLeafIndex(0); nLeafIndex< leafArray.size(); nLeafIndex++)
|
||||
{
|
||||
ST_NODE st_Node_Leaf;
|
||||
QJsonObject leafLevelObject = leafArray[nLeafIndex].toObject();
|
||||
makeStButton(st_Node_Leaf, leafLevelObject);
|
||||
QPair<int, ST_NODE> leafMap;
|
||||
leafMap.first = nItemNumber++;
|
||||
leafMap.second = st_Node_Leaf;
|
||||
map[nChildNumber].append(leafMap);
|
||||
}
|
||||
map[nTopNumber].append(childMap);
|
||||
}
|
||||
map[-1].append(topMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAccidentReviewDialog::makeStButton(ST_NODE &st_Node, const QJsonObject &object)
|
||||
{
|
||||
if(!object.value("name").isUndefined())
|
||||
{
|
||||
st_Node.name = object.value("name").toString();
|
||||
}
|
||||
if(!object.value("icon").isUndefined())
|
||||
{
|
||||
st_Node.icon = object.value("icon").toString();
|
||||
}
|
||||
if(!object.value("data").isUndefined())
|
||||
{
|
||||
st_Node.data = object.value("data").toString();
|
||||
}
|
||||
if(!object.value("opt").isUndefined())
|
||||
{
|
||||
st_Node.type = object.value("opt").toInt();
|
||||
}
|
||||
if(!object.value("used").isUndefined())
|
||||
{
|
||||
st_Node.used = object.value("used").toInt();
|
||||
}
|
||||
if(!object.value("web").isUndefined())
|
||||
{
|
||||
st_Node.web = object.value("web").toInt();
|
||||
}
|
||||
if(!object.value("webData").isUndefined())
|
||||
{
|
||||
st_Node.webData = object.value("webData").toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
#ifndef CACCIDENTREVIEWDIALOG_H
|
||||
#define CACCIDENTREVIEWDIALOG_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
#include <QMap>
|
||||
|
||||
struct ST_NODE
|
||||
{
|
||||
QString name;
|
||||
int used;
|
||||
int type;
|
||||
QString icon;
|
||||
int web;
|
||||
QString data;
|
||||
QString webData;
|
||||
};
|
||||
|
||||
class QTreeWidget;
|
||||
class QTreeWidgetItem;
|
||||
class CAccidentReviewDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Node_Enable{Enable = 1,Disable = 2};
|
||||
CAccidentReviewDialog(const QString &path, QWidget *parent = Q_NULLPTR);
|
||||
~CAccidentReviewDialog();
|
||||
|
||||
QString getCurrentGraph();
|
||||
|
||||
private slots:
|
||||
void slotConfirm();
|
||||
void slotCancel();
|
||||
|
||||
private:
|
||||
void initView();
|
||||
void initTree();
|
||||
void getFilterNames(const QString &path);
|
||||
QStringList getAllFile(const QString &path, const QString &relativePath,
|
||||
const QString &filter);
|
||||
void treeFilter();
|
||||
|
||||
void addChildLevelItem(QTreeWidgetItem *item, const QPair<int, ST_NODE> &node,
|
||||
const QMap<int, QList<QPair<int, ST_NODE> > > &navMap);
|
||||
QTreeWidgetItem* getAddLevelItem(const ST_NODE& st_node);
|
||||
void readNavJson(const QString &path, QMap<int, QList<QPair<int, ST_NODE>>>& map);
|
||||
void makeStButton(ST_NODE &st_Node, const QJsonObject &object);
|
||||
|
||||
private:
|
||||
QTreeWidget * m_treeWidget;
|
||||
QPushButton * m_confirmBtn;
|
||||
QPushButton * m_cancelBtn;
|
||||
QStringList m_fileNameList;
|
||||
};
|
||||
|
||||
#endif // CACCIDENTREVIEWDIALOG_H
|
||||
239
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmDataCollect.cpp
Normal file
239
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmDataCollect.cpp
Normal file
@ -0,0 +1,239 @@
|
||||
#include "CAiAlarmDataCollect.h"
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include "CAlarmMsgManage.h"
|
||||
#include <QDebug>
|
||||
#include "CAlarmDataCollect.h"
|
||||
using namespace iot_service;
|
||||
CAiAlarmDataCollect * CAiAlarmDataCollect::m_pInstance = NULL;
|
||||
CAiAlarmDataCollect::CAiAlarmDataCollect()
|
||||
: CIntelliAlmApi4Clt(),
|
||||
m_referenceCount(0),
|
||||
m_bFaultRecallState(false),
|
||||
m_pAlternateTimer(Q_NULLPTR)
|
||||
{
|
||||
m_rtdbMutex = new QMutex();
|
||||
m_rtdbPriorityOrderAccess = new iot_dbms::CRdbAccess();
|
||||
m_rtdbPriorityOrderAccess->open("base", "alarm_level_define");
|
||||
}
|
||||
|
||||
CAiAlarmDataCollect::~CAiAlarmDataCollect()
|
||||
{
|
||||
LOGDEBUG("CAiAlarmDataCollect::~CAiAlarmDataCollect()");
|
||||
qDebug() << "~CAiAlarmDataCollect()";
|
||||
}
|
||||
|
||||
void CAiAlarmDataCollect::refrence()
|
||||
{
|
||||
m_referenceCount++;
|
||||
}
|
||||
|
||||
int CAiAlarmDataCollect::getRefrenceCount()
|
||||
{
|
||||
return m_referenceCount;
|
||||
}
|
||||
|
||||
CAiAlarmDataCollect *CAiAlarmDataCollect::instance()
|
||||
{
|
||||
if(NULL == m_pInstance)
|
||||
{
|
||||
m_pInstance = new CAiAlarmDataCollect();
|
||||
}
|
||||
return m_pInstance;
|
||||
}
|
||||
|
||||
void CAiAlarmDataCollect::initialize()
|
||||
{
|
||||
resumeThread();
|
||||
if(!m_pAlternateTimer)
|
||||
{
|
||||
m_pAlternateTimer = new QTimer();
|
||||
m_pAlternateTimer->setInterval(1000);
|
||||
connect(m_pAlternateTimer, &QTimer::timeout, this, &CAiAlarmDataCollect::slotAiAlarmStateChanged);
|
||||
connect(this, &CAiAlarmDataCollect::sigTimerShot, this, &CAiAlarmDataCollect::slotTimerShot, Qt::QueuedConnection);
|
||||
}
|
||||
if(!m_bFaultRecallState)
|
||||
{
|
||||
emit sigTimerShot(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CAiAlarmDataCollect::release()
|
||||
{
|
||||
emit sigTimerShot(false);
|
||||
suspendThread(true);
|
||||
}
|
||||
|
||||
bool CAiAlarmDataCollect::isFaultRecallState()
|
||||
{
|
||||
return m_bFaultRecallState;
|
||||
}
|
||||
|
||||
bool CAiAlarmDataCollect::requestDelAlm(iot_idl::SIntelliAlmDel &objDelAlm)
|
||||
{
|
||||
LOGDEBUG("请求删除!");
|
||||
return iot_service::CIntelliAlmApi4Clt::requestDelAlm(objDelAlm);
|
||||
}
|
||||
|
||||
bool CAiAlarmDataCollect::requestSeprAlm(iot_idl::SIntelliAlmSepr &objSeprAlm)
|
||||
{
|
||||
LOGDEBUG("请求分离!");
|
||||
return iot_service::CIntelliAlmApi4Clt::requestSeprAlm(objSeprAlm);
|
||||
}
|
||||
|
||||
bool CAiAlarmDataCollect::requestMergeAlm(iot_idl::SIntelliAlmMerge &objMergeAlm)
|
||||
{
|
||||
LOGDEBUG("请求合并!");
|
||||
return iot_service::CIntelliAlmApi4Clt::requestMergeAlm(objMergeAlm);
|
||||
}
|
||||
|
||||
void CAiAlarmDataCollect::handleAllAlmMsg(int nDomainId, iot_idl::SIntelliAlmAdd &objAllAlm)
|
||||
{
|
||||
LOGINFO("========== AiAlarmDataCollect handleAllAlmMsg ==========");
|
||||
|
||||
//< 清空该域缓存
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
CAlarmMsgManage::instance()->removeAiAlarmMsgByDomainID(nDomainId);
|
||||
//构建告警
|
||||
int nAlarmCount = objAllAlm.alm_info_size();
|
||||
QList<AiAlarmMsgPtr> almList;
|
||||
for(int nAddMsgIndex(0); nAddMsgIndex < nAlarmCount; nAddMsgIndex++)
|
||||
{
|
||||
iot_idl::SIntelliAlmInfo msg = objAllAlm.alm_info(nAddMsgIndex);
|
||||
AiAlarmMsgPtr alm(new CAiAlarmMsgInfo());
|
||||
alm->initialize(msg);
|
||||
alm->priorityOrder = queryPriorityOrder(alm->priority);
|
||||
almList.append(alm);
|
||||
}
|
||||
CAlarmMsgManage::instance()->addAiAllAlarmMsg(almList);//添加全部完成后,通知model重新拉取数据
|
||||
LOGDEBUG("AiAlarmDataCollect handleAllAlmMsg():count[%d]",nAlarmCount);
|
||||
emit sigMsgRefresh();
|
||||
}
|
||||
|
||||
void CAiAlarmDataCollect::handleAddAlmMsg(iot_idl::SIntelliAlmAdd &objAddAlm)
|
||||
{
|
||||
LOGINFO("========== AiAlarmDataCollect handleAddAlmMsg ==========");
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
//构建告警
|
||||
int nAlarmCount = objAddAlm.alm_info_size();
|
||||
QList<AiAlarmMsgPtr> almList;
|
||||
for(int nAddMsgIndex(0); nAddMsgIndex < nAlarmCount; nAddMsgIndex++)
|
||||
{
|
||||
iot_idl::SIntelliAlmInfo msg = objAddAlm.alm_info(nAddMsgIndex);
|
||||
AiAlarmMsgPtr alm(new CAiAlarmMsgInfo());
|
||||
alm->initialize(msg);
|
||||
alm->priorityOrder = queryPriorityOrder(alm->priority);
|
||||
almList.append(alm);
|
||||
}
|
||||
CAlarmMsgManage::instance()->addAiAlarmMsg(almList); //单独添加的时候,来一条通知一次model添加
|
||||
LOGDEBUG("AiAlarmDataCollect handleAddAlmMsg():count[%d]",nAlarmCount);
|
||||
}
|
||||
|
||||
void CAiAlarmDataCollect::handleDelAlmMsg(iot_idl::SIntelliAlmDel &objDelAlm)
|
||||
{
|
||||
LOGINFO("========== AiAlarmDataCollect handleDelAlmMsg ==========");
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
//构建告警
|
||||
int nAlarmCount = objDelAlm.uuid_base64_size();
|
||||
QList<QString> uuidList;
|
||||
for(int nDelMsgIndex(0); nDelMsgIndex < nAlarmCount; nDelMsgIndex++)
|
||||
{
|
||||
QString uuid = QString::fromStdString(objDelAlm.uuid_base64(nDelMsgIndex));
|
||||
uuidList.append(uuid);
|
||||
}
|
||||
CAlarmMsgManage::instance()->delAiAlarmMsg(uuidList);
|
||||
LOGDEBUG("AiAlarmDataCollect handleDelAlmMsg():count[%d]",nAlarmCount);
|
||||
}
|
||||
|
||||
void CAiAlarmDataCollect::handleBrokenAlmMsg(iot_idl::SIntelliAlmBroken &objBrokenAlm)
|
||||
{
|
||||
//先保证能够编译通过
|
||||
LOGINFO("========== AiAlarmDataCollect handleBrokenAlmMsg ==========");
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
int nAlarmCount = objBrokenAlm.uuid_base64_size();
|
||||
QList<QString> uuidList;
|
||||
for(int nBrokenMsgIndex(0); nBrokenMsgIndex < nAlarmCount; nBrokenMsgIndex++)
|
||||
{
|
||||
QString uuid = QString::fromStdString(objBrokenAlm.uuid_base64(nBrokenMsgIndex));
|
||||
uuidList.append(uuid);
|
||||
}
|
||||
CAlarmMsgManage::instance()->brokenAiAlarmMsg(uuidList);
|
||||
LOGDEBUG("AiAlarmDataCollect handleBrokenAlmMsg():count[%d]",nAlarmCount);
|
||||
}
|
||||
|
||||
void CAiAlarmDataCollect::handleReleaseAlmMsg(iot_idl::SIntelliAlmRelease &objReleaseAlm)
|
||||
{
|
||||
//先保证能够编译通过
|
||||
LOGINFO("========== AiAlarmDataCollect handleReleaseAlmMsg ==========");
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
int nAlarmCount = objReleaseAlm.uuid_base64_size();
|
||||
QList<QString> uuidList;
|
||||
for(int nReleaseMsgIndex(0); nReleaseMsgIndex < nAlarmCount; nReleaseMsgIndex++)
|
||||
{
|
||||
QString uuid = QString::fromStdString(objReleaseAlm.uuid_base64(nReleaseMsgIndex));
|
||||
uuidList.append(uuid);
|
||||
}
|
||||
CAlarmMsgManage::instance()->releaseAiAlarmMsg(uuidList);
|
||||
LOGDEBUG("AiAlarmDataCollect handleReleaseAlmMsg():count[%d]",nAlarmCount);
|
||||
}
|
||||
|
||||
void CAiAlarmDataCollect::destory()
|
||||
{
|
||||
LOGINFO("退出时:CAiAlarmDataCollect::destory()打开窗口的个数m_referenceCount:[%d]",m_referenceCount);
|
||||
if(--m_referenceCount > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
slotTimerShot(false);
|
||||
suspendThread();
|
||||
{
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
if(Q_NULLPTR != m_pAlternateTimer)
|
||||
{
|
||||
m_pAlternateTimer->stop();
|
||||
m_pAlternateTimer->deleteLater();
|
||||
}
|
||||
m_pAlternateTimer = Q_NULLPTR;
|
||||
}
|
||||
delete m_rtdbMutex;
|
||||
delete m_rtdbPriorityOrderAccess;
|
||||
m_pInstance = NULL;
|
||||
delete this;
|
||||
}
|
||||
|
||||
void CAiAlarmDataCollect::slotTimerShot(const bool start)
|
||||
{
|
||||
if(m_pAlternateTimer)
|
||||
{
|
||||
if(start)
|
||||
{
|
||||
m_pAlternateTimer->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pAlternateTimer->stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAiAlarmDataCollect::slotSwitchFaultRecallState(bool bFaultRecallState)
|
||||
{
|
||||
m_bFaultRecallState = bFaultRecallState;
|
||||
release();
|
||||
m_pInstance->reinit(m_bFaultRecallState);
|
||||
CAlarmMsgManage::instance()->release();
|
||||
//initialize();
|
||||
}
|
||||
|
||||
int CAiAlarmDataCollect::queryPriorityOrder(int &id)
|
||||
{
|
||||
iot_dbms::CTableLockGuard locker(*m_rtdbPriorityOrderAccess);
|
||||
iot_dbms::CVarType value = -1000;
|
||||
m_rtdbPriorityOrderAccess->getColumnValueByKey((void*)&id, "priority_order", value);
|
||||
return value.toInt();
|
||||
}
|
||||
|
||||
void CAiAlarmDataCollect::slotAiAlarmStateChanged()
|
||||
{
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
CAlarmMsgManage::instance()->dealDelayAi();
|
||||
}
|
||||
84
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmDataCollect.h
Normal file
84
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmDataCollect.h
Normal file
@ -0,0 +1,84 @@
|
||||
#ifndef CAIALARMDATACOLLECT_H
|
||||
#define CAIALARMDATACOLLECT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
#include <QThread>
|
||||
#include <QMap>
|
||||
#include <QTimer>
|
||||
#include "IntelliAlmMsg.pb.h"
|
||||
#include "CAiAlarmMsgInfo.h"
|
||||
#include "net_msg_bus_api/MsgBusApi.h"
|
||||
#include "dbms/rdb_api/CRdbAccess.h"
|
||||
|
||||
class CAiAlarmDataCollect : public QObject, public iot_service::CIntelliAlmApi4Clt
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static CAiAlarmDataCollect *instance();
|
||||
|
||||
virtual ~CAiAlarmDataCollect();
|
||||
|
||||
void refrence();
|
||||
|
||||
int getRefrenceCount();
|
||||
|
||||
bool isFaultRecallState();
|
||||
|
||||
virtual bool requestDelAlm(iot_idl::SIntelliAlmDel &objDelAlm);
|
||||
|
||||
virtual bool requestSeprAlm(iot_idl::SIntelliAlmSepr &objSeprAlm);
|
||||
|
||||
virtual bool requestMergeAlm(iot_idl::SIntelliAlmMerge &objMergeAlm);
|
||||
|
||||
virtual void handleAllAlmMsg(int nDomainId,iot_idl::SIntelliAlmAdd &objAllAlm);
|
||||
|
||||
virtual void handleAddAlmMsg(iot_idl::SIntelliAlmAdd &objAddAlm);
|
||||
|
||||
virtual void handleDelAlmMsg(iot_idl::SIntelliAlmDel &objDelAlm);
|
||||
|
||||
virtual void handleBrokenAlmMsg(iot_idl::SIntelliAlmBroken &objBrokenAlm);
|
||||
|
||||
virtual void handleReleaseAlmMsg(iot_idl::SIntelliAlmRelease &objReleaseAlm);
|
||||
signals:
|
||||
//< 启停定时器
|
||||
void sigTimerShot(const bool bStop);
|
||||
|
||||
//< 定时更新,通知model刷新界面
|
||||
void sigUpdateAlarmView();
|
||||
|
||||
//< 通知所有告警插件禁用/使能告警操作
|
||||
void sigAlarmOperateEnable(const bool &bEnable);
|
||||
|
||||
//< 通知model重新拉取告警消息
|
||||
void sigMsgRefresh();
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
void initialize();
|
||||
|
||||
void release();
|
||||
|
||||
void destory();
|
||||
|
||||
void slotTimerShot(const bool start);
|
||||
|
||||
void slotSwitchFaultRecallState(bool bFaultRecallState);
|
||||
|
||||
private:
|
||||
CAiAlarmDataCollect();
|
||||
|
||||
int queryPriorityOrder(int &id);
|
||||
private slots:
|
||||
void slotAiAlarmStateChanged();
|
||||
private:
|
||||
int m_referenceCount;
|
||||
bool m_bFaultRecallState;
|
||||
QMutex *m_rtdbMutex;
|
||||
QTimer * m_pAlternateTimer;
|
||||
iot_dbms::CRdbAccess * m_rtdbPriorityOrderAccess;
|
||||
static CAiAlarmDataCollect * m_pInstance;
|
||||
};
|
||||
|
||||
#endif // CAIALARMDATACOLLECT_H
|
||||
408
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmDelegate.cpp
Normal file
408
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmDelegate.cpp
Normal file
@ -0,0 +1,408 @@
|
||||
#include "CAiAlarmDelegate.h"
|
||||
#include <QFile>
|
||||
#include "pub_utility_api/FileUtil.h"
|
||||
#include "pub_utility_api/FileStyle.h"
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include <QDomDocument>
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <QApplication>
|
||||
#include <QProcess>
|
||||
|
||||
CAiAlarmDelegate::CAiAlarmDelegate(CAiAlarmTreeModel *model, QObject *parent)
|
||||
: QStyledItemDelegate(parent),
|
||||
m_pModel(model),
|
||||
m_enableTrend(true),
|
||||
m_enableLevel(false),
|
||||
m_enableVideo(true),
|
||||
m_enableWave(true),
|
||||
m_selectIsEmpty(false)
|
||||
{
|
||||
slotLoadConfig();
|
||||
}
|
||||
|
||||
void CAiAlarmDelegate::setEnableTrend(bool isNeed)
|
||||
{
|
||||
m_enableTrend = isNeed;
|
||||
}
|
||||
|
||||
void CAiAlarmDelegate::setEnableLevel(bool isNeed)
|
||||
{
|
||||
m_enableLevel = isNeed;
|
||||
}
|
||||
|
||||
void CAiAlarmDelegate::setEnableVideo(bool isNeed)
|
||||
{
|
||||
m_enableVideo = isNeed;
|
||||
}
|
||||
|
||||
void CAiAlarmDelegate::setEnableWave(bool isNeed)
|
||||
{
|
||||
m_enableWave = isNeed;
|
||||
}
|
||||
|
||||
void CAiAlarmDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
if(!index.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
CAiAlarmTreeItem *item = m_pModel->getItem(index);
|
||||
|
||||
bool select = option.state & QStyle::State_Selected;
|
||||
QColor fillColor;
|
||||
QColor penColor;
|
||||
if(item->isAi())
|
||||
{
|
||||
AiAlarmMsgPtr aiptr = NULL;
|
||||
if(item->getAiPtr(aiptr) && aiptr != NULL)
|
||||
{
|
||||
painter->save();
|
||||
|
||||
if(CAlarmMsgManage::instance()->ifhaveNotConfirmAlmByuuid(aiptr->uuid_base64)) //包含的原始告警没有全部被确认
|
||||
{
|
||||
if(select)
|
||||
{
|
||||
fillColor = m_select_background_color;
|
||||
if(m_selectIsEmpty)
|
||||
{
|
||||
penColor = m_colorMap.value(aiptr->priorityOrder).active_text_color;
|
||||
}else
|
||||
{
|
||||
penColor = m_select_text_color;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(aiptr->main_state == E_ALS_RETURN || aiptr->main_state == E_ALS_RETURN_CFM
|
||||
|| aiptr->main_state == E_ALS_RETURN_DEL || aiptr->main_state == E_ALS_RETURN_CFM_DEL)
|
||||
{
|
||||
penColor = m_colorMap.value(aiptr->priorityOrder).resume_text_color;
|
||||
}else
|
||||
{
|
||||
penColor = m_colorMap.value(aiptr->priorityOrder).active_text_color;
|
||||
}
|
||||
|
||||
fillColor = m_colorMap.value(aiptr->priorityOrder).background_color;
|
||||
}
|
||||
}else //此条智能告警可以删除(置灰)
|
||||
{
|
||||
if(select)
|
||||
{
|
||||
fillColor = m_select_background_color;
|
||||
}
|
||||
else
|
||||
{
|
||||
fillColor = m_colorMap.value(aiptr->priorityOrder).confirm_color;
|
||||
}
|
||||
penColor = m_colorMap.value(aiptr->priorityOrder).confirm_text_color;
|
||||
}
|
||||
painter->setPen(penColor);
|
||||
painter->fillRect(option.rect, fillColor);
|
||||
if(m_enableVideo && BUTTON_COLUMN == index.column() && aiptr->m_needVideoAlm)
|
||||
{
|
||||
painter->save();
|
||||
QStyleOptionButton button;
|
||||
button.state |= QStyle::State_Enabled;
|
||||
button.rect = option.rect;
|
||||
|
||||
button.rect.adjust(option.rect.width() - 40, option.rect.height()/2-10, -12, -(option.rect.height()/2-10));
|
||||
button.iconSize = QSize(button.rect.width()+2,button.rect.height()+2);
|
||||
button.icon = QIcon(m_strVideoPath);
|
||||
button.features = QStyleOptionButton::Flat;
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButton,&button,painter);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
if(m_enableLevel && ICON_COLUMN == index.column())
|
||||
{
|
||||
painter->save();
|
||||
QStyleOptionButton button;
|
||||
button.state |= QStyle::State_Enabled;
|
||||
button.rect = option.rect;
|
||||
|
||||
button.rect.adjust(12, option.rect.height()/2-10, -(option.rect.width()-40), -(option.rect.height()/2-10));
|
||||
QString file = m_colorMap.value(aiptr->priorityOrder).icon;
|
||||
button.iconSize = QSize(button.rect.width()+2,button.rect.height()+2);
|
||||
button.icon = QIcon(file);
|
||||
button.features = QStyleOptionButton::Flat;
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButton,&button,painter);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
if( m_enableTrend && BUTTON_COLUMN == index.column() && (aiptr->m_tagname_type == E_TAGNAME_ANA || aiptr->m_tagname_type == E_TAGNAME_ACC))
|
||||
{
|
||||
painter->save();
|
||||
QStyleOptionButton button;
|
||||
button.state |= QStyle::State_Enabled;
|
||||
button.rect = option.rect;
|
||||
|
||||
button.rect.adjust(option.rect.width() - 40 -40, option.rect.height()/2-10, -12-40, -(option.rect.height()/2-10));
|
||||
button.iconSize = QSize(button.rect.width()+2,button.rect.height()+2);
|
||||
button.icon = QIcon(m_strTrendPath);
|
||||
button.features = QStyleOptionButton::Flat;
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButton,&button,painter);
|
||||
painter->restore();
|
||||
}
|
||||
painter->drawText(option.rect, m_pModel->data(index, Qt::TextAlignmentRole).toInt(), m_pModel->data(index).toString());
|
||||
painter->restore();
|
||||
}else
|
||||
{
|
||||
return ;
|
||||
}
|
||||
}else
|
||||
{
|
||||
AlarmMsgPtr ptr = NULL;
|
||||
if(item->getPtr(ptr) && ptr != NULL)
|
||||
{
|
||||
painter->save();
|
||||
if(ptr->logic_state == E_ALS_RETURN || ptr->logic_state == E_ALS_RETURN_DEL)//返回未确认
|
||||
{
|
||||
if(select)
|
||||
{
|
||||
fillColor = m_select_background_color;
|
||||
if(m_selectIsEmpty)
|
||||
{
|
||||
penColor = m_colorMap.value(ptr->priorityOrder).resume_text_color;
|
||||
}else
|
||||
{
|
||||
penColor = m_select_text_color;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
penColor = m_colorMap.value(ptr->priorityOrder).resume_text_color;
|
||||
fillColor = m_colorMap.value(ptr->priorityOrder).background_color;
|
||||
}
|
||||
}else if(ptr->logic_state == E_ALS_ALARM || ptr->logic_state == E_ALS_ALARM_DEL)//告警未确认
|
||||
{
|
||||
if(select)
|
||||
{
|
||||
fillColor = m_select_background_color;
|
||||
if(m_selectIsEmpty)
|
||||
{
|
||||
penColor = m_colorMap.value(ptr->priorityOrder).active_text_color;
|
||||
}else
|
||||
{
|
||||
penColor = m_select_text_color;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
penColor = m_colorMap.value(ptr->priorityOrder).active_text_color;
|
||||
fillColor = m_colorMap.value(ptr->priorityOrder).background_color;
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(select)
|
||||
{
|
||||
fillColor = m_select_background_color;
|
||||
}
|
||||
else
|
||||
{
|
||||
fillColor = m_colorMap.value(ptr->priorityOrder).confirm_color;
|
||||
}
|
||||
penColor = m_colorMap.value(ptr->priorityOrder).confirm_text_color;
|
||||
}
|
||||
painter->setPen(penColor);
|
||||
painter->fillRect(option.rect, fillColor);
|
||||
|
||||
if(m_enableVideo && BUTTON_COLUMN == index.column() && ptr->m_needVideoAlm)
|
||||
{
|
||||
painter->save();
|
||||
QStyleOptionButton button;
|
||||
button.state |= QStyle::State_Enabled;
|
||||
button.rect = option.rect;
|
||||
|
||||
button.rect.adjust(option.rect.width() - 40, option.rect.height()/2-10, -12, -(option.rect.height()/2-10));
|
||||
button.iconSize = QSize(button.rect.width()+2,button.rect.height()+2);
|
||||
button.icon = QIcon(m_strVideoPath);
|
||||
button.features = QStyleOptionButton::Flat;
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButton,&button,painter);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
if(m_enableLevel && ICON_COLUMN == index.column())
|
||||
{
|
||||
painter->save();
|
||||
QStyleOptionButton button;
|
||||
button.state |= QStyle::State_Enabled;
|
||||
button.rect = option.rect;
|
||||
|
||||
button.rect.adjust(12, option.rect.height()/2-10, -(option.rect.width()-40), -(option.rect.height()/2-10));
|
||||
QString file = m_colorMap.value(ptr->priorityOrder).icon;
|
||||
button.iconSize = QSize(button.rect.width()+2,button.rect.height()+2);
|
||||
button.icon = QIcon(file);
|
||||
button.features = QStyleOptionButton::Flat;
|
||||
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButton,&button,painter);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
if( m_enableTrend && BUTTON_COLUMN == index.column() && (ptr->m_tagname_type == E_TAGNAME_ANA || ptr->m_tagname_type == E_TAGNAME_ACC))
|
||||
{
|
||||
painter->save();
|
||||
QStyleOptionButton button;
|
||||
button.state |= QStyle::State_Enabled;
|
||||
button.rect = option.rect;
|
||||
|
||||
button.rect.adjust(option.rect.width() - 40 -40, option.rect.height()/2-10, -12-40, -(option.rect.height()/2-10));
|
||||
button.iconSize = QSize(button.rect.width()+2,button.rect.height()+2);
|
||||
button.icon = QIcon(m_strTrendPath);
|
||||
button.features = QStyleOptionButton::Flat;
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButton,&button,painter);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
if( m_enableWave && BUTTON_COLUMN == index.column() && !ptr->wave_file.isEmpty())
|
||||
{
|
||||
painter->save();
|
||||
QStyleOptionButton button;
|
||||
button.state |= QStyle::State_Enabled;
|
||||
button.rect = option.rect;
|
||||
|
||||
button.rect.adjust(option.rect.width() - 40 -40 -40, option.rect.height()/2-10, -12-40-40, -(option.rect.height()/2-10));
|
||||
button.iconSize = QSize(button.rect.width()+2,button.rect.height()+2);
|
||||
button.icon = QIcon(m_strWavePath);
|
||||
button.features = QStyleOptionButton::Flat;
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButton,&button,painter);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
painter->drawText(option.rect, m_pModel->data(index, Qt::TextAlignmentRole).toInt(), m_pModel->data(index).toString());
|
||||
painter->restore();
|
||||
}else
|
||||
{
|
||||
return ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CAiAlarmDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
|
||||
{
|
||||
if(!index.isValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(index.column() != BUTTON_COLUMN)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
CAiAlarmTreeItem *item = m_pModel->getItem(index);
|
||||
if(item->isAi())
|
||||
{
|
||||
AiAlarmMsgPtr ptr = NULL;
|
||||
if(item->getAiPtr(ptr) && ptr != NULL)
|
||||
{
|
||||
if(mouseEvent != NULL && mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
if(m_enableVideo && ptr->m_needVideoAlm)
|
||||
{
|
||||
QStyleOptionButton button;
|
||||
button.rect = option.rect;
|
||||
button.rect.adjust(option.rect.width() - 42, option.rect.height()/2-10, -10, -(option.rect.height()/2-10));
|
||||
QRect rect = button.rect;
|
||||
if(rect.contains(mouseEvent->pos()))
|
||||
{
|
||||
QString pointTag = ptr->key_id_tag;
|
||||
pointTag.remove(pointTag.length()-6,6);
|
||||
emit openVideo(ptr->domain_id,ptr->app_id,pointTag,ptr->time_stamp-VIDEO_TIME,ptr->time_stamp+VIDEO_TIME);
|
||||
}
|
||||
}
|
||||
if( m_enableTrend && (ptr->m_tagname_type == E_TAGNAME_ACC || ptr->m_tagname_type == E_TAGNAME_ANA))
|
||||
{
|
||||
QStyleOptionButton button;
|
||||
button.rect = option.rect;
|
||||
button.rect.adjust(option.rect.width() - 82, option.rect.height()/2-10, -50, -(option.rect.height()/2-10));
|
||||
QRect rect = button.rect;
|
||||
|
||||
if(rect.contains(mouseEvent->pos()))
|
||||
{
|
||||
QStringList trendList;
|
||||
trendList.append(ptr->key_id_tag);
|
||||
emit openTrend(ptr->time_stamp,trendList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else
|
||||
{
|
||||
AlarmMsgPtr ptr = NULL;
|
||||
if(item->getPtr(ptr) && ptr != NULL)
|
||||
{
|
||||
if(m_enableVideo && ptr->m_needVideoAlm)
|
||||
{
|
||||
if(mouseEvent != NULL && mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
QStyleOptionButton button;
|
||||
button.rect = option.rect;
|
||||
button.rect.adjust(option.rect.width() - 42, option.rect.height()/2-10, -10, -(option.rect.height()/2-10));
|
||||
QRect rect = button.rect;
|
||||
QString pointTag = ptr->key_id_tag;
|
||||
pointTag.remove(pointTag.length()-6,6);
|
||||
if(rect.contains(mouseEvent->pos()))
|
||||
{
|
||||
QString pointTag = ptr->key_id_tag;
|
||||
pointTag.remove(pointTag.length()-6,6);
|
||||
emit openVideo(ptr->domain_id,ptr->app_id,pointTag,ptr->time_stamp-VIDEO_TIME,ptr->time_stamp+VIDEO_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(m_enableTrend && (ptr->m_tagname_type == E_TAGNAME_ACC || ptr->m_tagname_type == E_TAGNAME_ANA))
|
||||
{
|
||||
if(mouseEvent != NULL && mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
QStyleOptionButton button;
|
||||
button.rect = option.rect;
|
||||
button.rect.adjust(option.rect.width() - 82, option.rect.height()/2-10, -50, -(option.rect.height()/2-10));
|
||||
QRect rect = button.rect;
|
||||
if(rect.contains(mouseEvent->pos()))
|
||||
{
|
||||
QStringList trendList;
|
||||
trendList.append(ptr->key_id_tag);
|
||||
emit openTrend(ptr->time_stamp,trendList);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(m_enableWave && !ptr->wave_file.isEmpty())
|
||||
{
|
||||
if(mouseEvent != NULL && mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
QStyleOptionButton button;
|
||||
button.rect = option.rect;
|
||||
button.rect.adjust(option.rect.width() - 122, option.rect.height()/2-10, -90, -(option.rect.height()/2-10));
|
||||
QRect rect = button.rect;
|
||||
if(rect.contains(mouseEvent->pos()))
|
||||
{
|
||||
QString wave = ptr->wave_file;
|
||||
wave = QString("%1%2%3").arg("\"").arg(wave).arg("\"");
|
||||
LOGINFO("录波文件为:%s",wave.toStdString().c_str());
|
||||
|
||||
const std::string strProc = std::move(iot_public::CFileUtil::getPathOfBinFile(
|
||||
std::string("WaveAnalyze") + iot_public::CFileUtil::getProcSuffix()));
|
||||
if(strProc.empty())
|
||||
LOGERROR("未找到可执行文件WaveAnalyze");
|
||||
else
|
||||
QProcess::startDetached(QString("%1 %2").arg(strProc.c_str()).arg(wave));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return QStyledItemDelegate::editorEvent(event, model, option, index);
|
||||
}
|
||||
|
||||
void CAiAlarmDelegate::slotLoadConfig()
|
||||
{
|
||||
CAlarmSetMng::instance()->getColorMap(m_colorMap);
|
||||
CAlarmSetMng::instance()->getSelectInfo(m_selectIsEmpty,m_select_background_color,m_select_text_color);
|
||||
CAlarmSetMng::instance()->getEmptyInfo(m_emptyBackgroundColor,m_emptyTipColor,m_emptyTip);
|
||||
//CAlarmColorMng::instance()->getActAndFunc(m_act,m_func);
|
||||
|
||||
std::string style = iot_public::CFileStyle::getCurStyle();
|
||||
m_strTrendPath = iot_public::CFileUtil::getPathOfResFile("gui/icon/alarm/trend_"+style+".png").c_str();
|
||||
m_strVideoPath = iot_public::CFileUtil::getPathOfResFile("gui/icon/alarm/video_"+style+".png").c_str();
|
||||
m_strWavePath = iot_public::CFileUtil::getPathOfResFile("gui/icon/alarm/wave_"+style+".png").c_str();
|
||||
}
|
||||
50
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmDelegate.h
Normal file
50
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmDelegate.h
Normal file
@ -0,0 +1,50 @@
|
||||
#ifndef CAIALARMDELEGATE_H
|
||||
#define CAIALARMDELEGATE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QStyledItemDelegate>
|
||||
#include "CAiAlarmTreeModel.h"
|
||||
#include "CAlarmSetMng.h"
|
||||
|
||||
class CAiAlarmDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CAiAlarmDelegate(CAiAlarmTreeModel *model, QObject *parent = 0);
|
||||
void setEnableTrend(bool isNeed);
|
||||
void setEnableLevel(bool isNeed);
|
||||
void setEnableVideo(bool isNeed);
|
||||
void setEnableWave(bool isNeed);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index);
|
||||
signals:
|
||||
void openVideo(int domainId,int appId,QString tag,quint64 startTime,quint64 endTime);
|
||||
void openTrend(quint64 time_stamp,QStringList tagList);
|
||||
|
||||
public slots:
|
||||
void slotLoadConfig();
|
||||
|
||||
private:
|
||||
CAiAlarmTreeModel *m_pModel;
|
||||
|
||||
bool m_enableTrend;
|
||||
bool m_enableLevel;
|
||||
bool m_enableVideo;
|
||||
bool m_enableWave;
|
||||
|
||||
QMap<int,CAlarmColorInfo> m_colorMap;
|
||||
QColor m_select_background_color,m_select_text_color; //选中告警背景色和文字颜色
|
||||
bool m_selectIsEmpty;
|
||||
|
||||
QColor m_emptyBackgroundColor,m_emptyTipColor;
|
||||
QString m_emptyTip;
|
||||
int m_act;
|
||||
int m_func;
|
||||
|
||||
QString m_strWavePath;
|
||||
QString m_strVideoPath;
|
||||
QString m_strTrendPath;
|
||||
};
|
||||
|
||||
#endif // CAIALARMDELEGATE_H
|
||||
466
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmMsgInfo.cpp
Normal file
466
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmMsgInfo.cpp
Normal file
@ -0,0 +1,466 @@
|
||||
#include "CAiAlarmMsgInfo.h"
|
||||
#include <QDateTime>
|
||||
#include "CAlarmDataCollect.h"
|
||||
#include <QDebug>
|
||||
|
||||
CAiAlarmMsgInfo::CAiAlarmMsgInfo()
|
||||
{
|
||||
logic_state = E_AiALM_IALS_NORMAL;
|
||||
main_state = E_ALS_BAD;
|
||||
domain_id = -1;
|
||||
priority = -1;
|
||||
time_stamp = 1000;
|
||||
|
||||
uuid_base64 = QString();
|
||||
content = QString();
|
||||
disposal_plan = QString();
|
||||
raw_alm_uuid.clear();
|
||||
|
||||
priorityOrder = -1;
|
||||
deleteFlag = false;
|
||||
brokenFlag = false;
|
||||
releaseFlag = false;
|
||||
m_needVideoAlm =false;
|
||||
app_id = -1;
|
||||
main_uuid_base64 = QString();
|
||||
key_id_tag = QString();
|
||||
m_tagname_type = E_TAGNAME_ERROR;
|
||||
}
|
||||
|
||||
CAiAlarmMsgInfo::CAiAlarmMsgInfo(const CAiAlarmMsgInfo &other): priority(0)
|
||||
{
|
||||
logic_state = other.logic_state;
|
||||
main_state = other.main_state;
|
||||
domain_id = other.domain_id;
|
||||
time_stamp = other.time_stamp;
|
||||
|
||||
uuid_base64 = other.uuid_base64;
|
||||
content = other.content;
|
||||
disposal_plan = other.disposal_plan;
|
||||
raw_alm_uuid = other.raw_alm_uuid;
|
||||
|
||||
priorityOrder = other.priorityOrder;
|
||||
deleteFlag = other.deleteFlag;
|
||||
brokenFlag = other.brokenFlag;
|
||||
releaseFlag = other.releaseFlag;
|
||||
|
||||
m_needVideoAlm = other.m_needVideoAlm;
|
||||
app_id = other.app_id;
|
||||
main_uuid_base64 = other.main_uuid_base64;
|
||||
key_id_tag = other.key_id_tag;
|
||||
m_tagname_type = other.m_tagname_type;
|
||||
}
|
||||
|
||||
void CAiAlarmMsgInfo::initialize(const iot_idl::SIntelliAlmInfo &alarmInfo)
|
||||
{
|
||||
|
||||
logic_state = (E_AiALARM_LOGICSTATE)alarmInfo.logic_state();
|
||||
domain_id = alarmInfo.domain_id();
|
||||
priority = alarmInfo.priority();
|
||||
time_stamp = alarmInfo.time_stamp();
|
||||
|
||||
uuid_base64 = QString::fromStdString(alarmInfo.uuid_base64());
|
||||
content = QString::fromStdString(alarmInfo.content());
|
||||
disposal_plan = QString::fromStdString(alarmInfo.disposal_plan());
|
||||
raw_alm_uuid.clear(); //< 关联的原始告警uuid
|
||||
for(int x(0); x < alarmInfo.raw_alm_uuid_size(); x++)
|
||||
{
|
||||
if(x == 0)
|
||||
{
|
||||
main_uuid_base64 = QString::fromStdString(alarmInfo.raw_alm_uuid(x));
|
||||
}
|
||||
raw_alm_uuid.append(QString::fromStdString(alarmInfo.raw_alm_uuid(x)));
|
||||
}
|
||||
|
||||
priorityOrder = -1;
|
||||
if(logic_state == E_AIALM_IALS_DELETED)
|
||||
{
|
||||
deleteFlag = true;
|
||||
}else
|
||||
{
|
||||
deleteFlag = false;
|
||||
}
|
||||
if(logic_state == E_AIALM_IALS_BROKEN)
|
||||
{
|
||||
brokenFlag = true;
|
||||
}else
|
||||
{
|
||||
brokenFlag = false;
|
||||
}
|
||||
releaseFlag = false;
|
||||
m_needVideoAlm =false;
|
||||
}
|
||||
|
||||
bool CAiAlarmMsgInfo::ailessThan(const AlarmMsgPtr &info, E_ALARM_SORTKEY sortkey)
|
||||
{
|
||||
switch (sortkey) {
|
||||
case E_SORT_PRIORITY:
|
||||
if(priorityOrder > info->priorityOrder)
|
||||
{
|
||||
return true;
|
||||
}else if(priorityOrder < info->priorityOrder)
|
||||
{
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
if(time_stamp < info->time_stamp)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case E_SORT_TIME:
|
||||
if(time_stamp < info->time_stamp)
|
||||
{
|
||||
return true;
|
||||
}else if(time_stamp > info->time_stamp)
|
||||
{
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
if(priorityOrder > info->priorityOrder)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case E_SORT_LOCATION:
|
||||
return false;
|
||||
break;
|
||||
case E_SORT_REGION:
|
||||
return false;
|
||||
break;
|
||||
case E_SORT_TYPE:
|
||||
return false;
|
||||
break;
|
||||
case E_SORT_CONTENT:
|
||||
if(content.isEmpty() && info->content.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(content.isEmpty() && (!info->content.isEmpty()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if((!content.isEmpty()) && info->content.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(content < info->content)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(content > info->content)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(time_stamp < info->time_stamp)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case E_SORT_LOGICSTATE:
|
||||
return false;
|
||||
case E_SORT_ALM_STATE:
|
||||
return false;
|
||||
break;
|
||||
case E_SORT_STYLE:
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CAiAlarmMsgInfo::aimoreThan(const AlarmMsgPtr &info, E_ALARM_SORTKEY sortkey)
|
||||
{
|
||||
switch (sortkey) {
|
||||
case E_SORT_PRIORITY:
|
||||
if(priorityOrder < info->priorityOrder)
|
||||
{
|
||||
return true;
|
||||
}else if(priorityOrder > info->priorityOrder)
|
||||
{
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
if(time_stamp < info->time_stamp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case E_SORT_TIME:
|
||||
if(time_stamp > info->time_stamp)
|
||||
{
|
||||
return true;
|
||||
}else if(time_stamp < info->time_stamp)
|
||||
{
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
if(priorityOrder < info->priorityOrder)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case E_SORT_LOCATION:
|
||||
return true;
|
||||
break;
|
||||
case E_SORT_REGION:
|
||||
return true;
|
||||
break;
|
||||
case E_SORT_TYPE:
|
||||
return true;
|
||||
break;
|
||||
case E_SORT_CONTENT:
|
||||
if(content.isEmpty() && info->content.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(content.isEmpty() && (!info->content.isEmpty()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if((!content.isEmpty()) && info->content.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(content < info->content)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(content > info->content)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(time_stamp < info->time_stamp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case E_SORT_LOGICSTATE:
|
||||
return true;
|
||||
break;
|
||||
case E_SORT_ALM_STATE:
|
||||
return true;
|
||||
break;
|
||||
case E_SORT_STYLE:
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//< 智能告警-前者小[不包含的字段进行比较排序]
|
||||
bool CAiAlarmMsgInfo::ailessThan(const AiAlarmMsgPtr &info, E_ALARM_SORTKEY sortkey)
|
||||
{
|
||||
switch (sortkey) {
|
||||
case E_SORT_PRIORITY:
|
||||
if(priorityOrder > info->priorityOrder)
|
||||
{
|
||||
return true;
|
||||
}else if(priorityOrder < info->priorityOrder)
|
||||
{
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
if(time_stamp < info->time_stamp)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case E_SORT_TIME:
|
||||
if(time_stamp < info->time_stamp)
|
||||
{
|
||||
return true;
|
||||
}else if(time_stamp > info->time_stamp)
|
||||
{
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
if(priorityOrder > info->priorityOrder)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case E_SORT_LOCATION:
|
||||
return true;
|
||||
break;
|
||||
case E_SORT_REGION:
|
||||
return true;
|
||||
break;
|
||||
case E_SORT_TYPE:
|
||||
return true;
|
||||
break;
|
||||
case E_SORT_CONTENT:
|
||||
if(content.isEmpty() && info->content.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(content.isEmpty() && (!info->content.isEmpty()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if((!content.isEmpty()) && info->content.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(content < info->content)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(content > info->content)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(time_stamp < info->time_stamp)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case E_SORT_LOGICSTATE:
|
||||
return true;
|
||||
case E_SORT_ALM_STATE:
|
||||
return true;
|
||||
break;
|
||||
case E_SORT_STYLE:
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CAiAlarmMsgInfo::aimoreThan(const AiAlarmMsgPtr &info, E_ALARM_SORTKEY sortkey)
|
||||
{
|
||||
switch (sortkey) {
|
||||
case E_SORT_PRIORITY:
|
||||
if(priorityOrder < info->priorityOrder)
|
||||
{
|
||||
return true;
|
||||
}else if(priorityOrder > info->priorityOrder)
|
||||
{
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
if(time_stamp < info->time_stamp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case E_SORT_TIME:
|
||||
if(time_stamp > info->time_stamp)
|
||||
{
|
||||
return true;
|
||||
}else if(time_stamp < info->time_stamp)
|
||||
{
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
if(priorityOrder < info->priorityOrder)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case E_SORT_LOCATION:
|
||||
return false;
|
||||
break;
|
||||
case E_SORT_REGION:
|
||||
return false;
|
||||
break;
|
||||
case E_SORT_TYPE:
|
||||
return false;
|
||||
break;
|
||||
case E_SORT_CONTENT:
|
||||
if(content.isEmpty() && info->content.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(content.isEmpty() && (!info->content.isEmpty()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if((!content.isEmpty()) && info->content.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(content < info->content)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(content > info->content)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(time_stamp < info->time_stamp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case E_SORT_LOGICSTATE:
|
||||
return false;
|
||||
break;
|
||||
case E_SORT_ALM_STATE:
|
||||
return false;
|
||||
break;
|
||||
case E_SORT_STYLE:
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator==(const CAiAlarmMsgInfo &source, const CAiAlarmMsgInfo &target)
|
||||
{
|
||||
if(source.uuid_base64 == target.uuid_base64)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// //替换式告警且车站、测点ID相同
|
||||
// if((0 == source.if_water_alm) && (0 == target.if_water_alm) && (source.location_id == target.location_id) && (source.key_id_tag == target.key_id_tag))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// //流水账告警且时标、告警内容相同
|
||||
// else if((1 == source.if_water_alm) && (1 == target.if_water_alm) && (source.location_id == target.location_id) && (source.time_stamp == target.time_stamp) && (source.content == target.content))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
}
|
||||
60
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmMsgInfo.h
Normal file
60
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmMsgInfo.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef CAIALARMMSGINFO_H
|
||||
#define CAIALARMMSGINFO_H
|
||||
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QStringList>
|
||||
#include <QSharedPointer>
|
||||
#include "intelli_alm_api/CIntelliAlmApi4Clt.h"
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
#include <CAlarmCommon.h>
|
||||
#include <CAlarmMsgInfo.h>
|
||||
enum E_AiALARM_LOGICSTATE
|
||||
{
|
||||
E_AiALM_IALS_NORMAL = 1, //正常
|
||||
E_AIALM_IALS_DELETED = 2, //已删除
|
||||
E_AIALM_IALS_BROKEN = 3, //不完整的
|
||||
};
|
||||
class CAiAlarmMsgInfo
|
||||
{
|
||||
public:
|
||||
CAiAlarmMsgInfo();
|
||||
CAiAlarmMsgInfo(const CAiAlarmMsgInfo &other);
|
||||
void initialize(const iot_idl::SIntelliAlmInfo &alarmInfo);
|
||||
|
||||
//< [优先级越小表示越大]-智能告警窗调用
|
||||
bool ailessThan(const AlarmMsgPtr &info, E_ALARM_SORTKEY sortkey = E_SORT_PRIORITY);
|
||||
bool aimoreThan(const AlarmMsgPtr &info, E_ALARM_SORTKEY sortkey = E_SORT_PRIORITY);
|
||||
|
||||
bool ailessThan(const AiAlarmMsgPtr &info, E_ALARM_SORTKEY sortkey = E_SORT_PRIORITY);
|
||||
bool aimoreThan(const AiAlarmMsgPtr &info, E_ALARM_SORTKEY sortkey = E_SORT_PRIORITY);
|
||||
|
||||
E_AiALARM_LOGICSTATE logic_state; //< 状态
|
||||
E_ALARM_LOGICSTATE main_state; //< 主告警逻辑状态
|
||||
qint32 domain_id; //< 域ID
|
||||
qint32 priority; //< 告警优先级id
|
||||
quint64 time_stamp; //< 时标(RFC1305、POSIX时标标准)
|
||||
QString uuid_base64; //< uuid 主键
|
||||
QString content; //< 告警内容
|
||||
QString disposal_plan; //< 处置预案
|
||||
QVector<QString> raw_alm_uuid; //< 关联的原始告警uuid
|
||||
//< Extend
|
||||
qint32 priorityOrder; //< 优先级
|
||||
bool deleteFlag; //< 是否被删除
|
||||
bool brokenFlag; //< 是否不完整
|
||||
bool releaseFlag; //< 是否被释放
|
||||
//和主原始告警相关
|
||||
bool m_needVideoAlm; //是否需要视频告警
|
||||
qint32 app_id; //主原始告警应用id
|
||||
QString main_uuid_base64; //主原始告警uuid
|
||||
QString key_id_tag; //主原始告警标签
|
||||
E_TAGNAME_TYPE m_tagname_type;
|
||||
};
|
||||
|
||||
bool operator==(const CAiAlarmMsgInfo &source, const CAiAlarmMsgInfo &target);
|
||||
|
||||
Q_DECLARE_METATYPE(CAiAlarmMsgInfo)
|
||||
Q_DECLARE_METATYPE(AiAlarmMsgPtr)
|
||||
|
||||
#endif // CAIALARMMSGINFO_H
|
||||
416
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmTreeItem.cpp
Normal file
416
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmTreeItem.cpp
Normal file
@ -0,0 +1,416 @@
|
||||
#include "CAiAlarmTreeItem.h"
|
||||
#include "CAiAlarmMsgInfo.h"
|
||||
#include "CAlarmMsgInfo.h"
|
||||
#include "CAlarmCommon.h"
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include <QDateTime>
|
||||
#include <QMap>
|
||||
#include "CAlarmBaseData.h"
|
||||
CAiAlarmTreeItem::CAiAlarmTreeItem(const QVector<QVariant> &data, CAiAlarmTreeItem *parent)
|
||||
: m_uuid(QString()),
|
||||
m_bIsAi(false),
|
||||
m_parent(parent),
|
||||
m_data(data),
|
||||
m_alarmPtr(NULL),
|
||||
m_aialarmPtr(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CAiAlarmTreeItem::~CAiAlarmTreeItem()
|
||||
{
|
||||
qDeleteAll(m_child);
|
||||
m_child.clear();
|
||||
}
|
||||
|
||||
CAiAlarmTreeItem *CAiAlarmTreeItem::child(int row)
|
||||
{
|
||||
return m_child.at(row);
|
||||
}
|
||||
|
||||
CAiAlarmTreeItem *CAiAlarmTreeItem::parent()
|
||||
{
|
||||
return m_parent;
|
||||
}
|
||||
|
||||
int CAiAlarmTreeItem::childCount() const
|
||||
{
|
||||
return m_child.count();
|
||||
}
|
||||
|
||||
int CAiAlarmTreeItem::columnCount() const
|
||||
{
|
||||
return m_data.count();
|
||||
}
|
||||
|
||||
int CAiAlarmTreeItem::childNumber() const
|
||||
{
|
||||
if(m_parent)
|
||||
{
|
||||
return m_parent->m_child.indexOf(const_cast<CAiAlarmTreeItem*>(this));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QVariant CAiAlarmTreeItem::data(int column, int role)
|
||||
{
|
||||
if(E_DisplayRole == role)
|
||||
{
|
||||
if(m_bIsAi == true)
|
||||
{
|
||||
return aigetDataByColumn(column);
|
||||
}else
|
||||
{
|
||||
return getDataByColumn(column);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
bool CAiAlarmTreeItem::setData(int column, const QVariant &value, int role)
|
||||
{
|
||||
Q_UNUSED(role)
|
||||
Q_UNUSED(value)
|
||||
if (column < 0 || column >= m_data.size())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAiAlarmTreeItem::setPtr(AlarmMsgPtr ptr)
|
||||
{
|
||||
m_alarmPtr = ptr;
|
||||
m_bIsAi = false;
|
||||
m_uuid = ptr->uuid_base64;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAiAlarmTreeItem::setAiPtr(AiAlarmMsgPtr aiPtr)
|
||||
{
|
||||
m_aialarmPtr = aiPtr;
|
||||
m_bIsAi = true;
|
||||
m_uuid = aiPtr->uuid_base64;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAiAlarmTreeItem::insertChildren(int position, int count, int columns)
|
||||
{
|
||||
if (position < 0 || position > m_child.size())
|
||||
return false;
|
||||
|
||||
for (int row = 0; row < count; ++row) {
|
||||
QVector<QVariant> data(columns);
|
||||
CAiAlarmTreeItem *item = new CAiAlarmTreeItem(data, this);
|
||||
m_child.insert(position, item);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAiAlarmTreeItem::removeChildren(int position, int count, int columns)
|
||||
{
|
||||
Q_UNUSED(columns)
|
||||
if (position < 0 || position + count > m_child.size())
|
||||
return false;
|
||||
|
||||
for (int row = 0; row < count; ++row)
|
||||
delete m_child.takeAt(position);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAiAlarmTreeItem::isAi()
|
||||
{
|
||||
return m_bIsAi;
|
||||
}
|
||||
|
||||
AlarmMsgPtr CAiAlarmTreeItem::ptr()
|
||||
{
|
||||
if(m_alarmPtr == NULL)
|
||||
return NULL;
|
||||
else
|
||||
return m_alarmPtr;
|
||||
}
|
||||
|
||||
bool CAiAlarmTreeItem::getPtr(AlarmMsgPtr &ptr)
|
||||
{
|
||||
if(!m_bIsAi &&m_alarmPtr != NULL)
|
||||
{
|
||||
ptr = m_alarmPtr;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CAiAlarmTreeItem::getAiPtr(AiAlarmMsgPtr &aiPtr)
|
||||
{
|
||||
if(m_bIsAi &&m_aialarmPtr != NULL)
|
||||
{
|
||||
aiPtr = m_aialarmPtr;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
aiPtr = NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QList<AlarmMsgPtr> CAiAlarmTreeItem::getChildAlarmPtr()
|
||||
{
|
||||
QList<AlarmMsgPtr> ptrList;
|
||||
foreach (CAiAlarmTreeItem* item, m_child) {
|
||||
if(item->ptr() != NULL)
|
||||
{
|
||||
ptrList.append(item->ptr());
|
||||
}
|
||||
}
|
||||
return ptrList;
|
||||
}
|
||||
|
||||
int CAiAlarmTreeItem::index(const QString uuid)
|
||||
{
|
||||
for(int index(0);index<m_child.count();index++)
|
||||
{
|
||||
if(m_child.at(index)->m_uuid == uuid)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool CAiAlarmTreeItem::lessThan(CAiAlarmTreeItem *info, E_ALARM_SORTKEY sortkey)
|
||||
{
|
||||
AiAlarmMsgPtr aiptr = NULL;
|
||||
AlarmMsgPtr ptr= NULL;
|
||||
if(m_bIsAi)
|
||||
{
|
||||
if(info->isAi())
|
||||
{
|
||||
if(info->getAiPtr(aiptr) && aiptr != NULL)
|
||||
return m_aialarmPtr->ailessThan(aiptr,sortkey);
|
||||
}else
|
||||
{
|
||||
if(info->getPtr(ptr) && ptr != NULL)
|
||||
return m_aialarmPtr->ailessThan(ptr,sortkey);
|
||||
}
|
||||
|
||||
}else
|
||||
{
|
||||
if(info->isAi())
|
||||
{
|
||||
if(info->getAiPtr(aiptr) && aiptr != NULL)
|
||||
return m_alarmPtr->ailessThan(aiptr,sortkey);
|
||||
}else
|
||||
{
|
||||
if(info->getPtr(ptr) && ptr != NULL)
|
||||
return m_alarmPtr->ailessThan(ptr,sortkey);
|
||||
}
|
||||
}
|
||||
LOGERROR("lessThan():比较大小出错!");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CAiAlarmTreeItem::moreThan(CAiAlarmTreeItem *info, E_ALARM_SORTKEY sortkey)
|
||||
{
|
||||
AiAlarmMsgPtr aiptr = NULL;
|
||||
AlarmMsgPtr ptr= NULL;
|
||||
if(m_bIsAi)
|
||||
{
|
||||
if(info->isAi())
|
||||
{
|
||||
if(info->getAiPtr(aiptr) && aiptr != NULL)
|
||||
return m_aialarmPtr->aimoreThan(aiptr,sortkey);
|
||||
}else
|
||||
{
|
||||
if(info->getPtr(ptr) && ptr != NULL)
|
||||
return m_aialarmPtr->aimoreThan(ptr,sortkey);
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(info->isAi())
|
||||
{
|
||||
if(info->getAiPtr(aiptr) && aiptr != NULL)
|
||||
return m_alarmPtr->aimoreThan(aiptr,sortkey);
|
||||
}else
|
||||
{
|
||||
if(info->getPtr(ptr) && ptr != NULL)
|
||||
return m_alarmPtr->aimoreThan(ptr,sortkey);
|
||||
}
|
||||
}
|
||||
LOGERROR("moreThan():比较大小出错!");
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<CAiAlarmTreeItem *> CAiAlarmTreeItem::getChild()
|
||||
{
|
||||
return m_child;
|
||||
}
|
||||
|
||||
void CAiAlarmTreeItem::setChild(QList<CAiAlarmTreeItem *> itemList)
|
||||
{
|
||||
m_child.clear();
|
||||
m_child = itemList;
|
||||
}
|
||||
|
||||
QList<CAiAlarmTreeItem *> CAiAlarmTreeItem::getChildItemList()
|
||||
{
|
||||
return m_child;
|
||||
}
|
||||
|
||||
QVector<QString> CAiAlarmTreeItem::getContent()
|
||||
{
|
||||
QVector<QString> vec;
|
||||
for(int index(0);index<m_data.size();index++)
|
||||
{
|
||||
vec.append(m_data[index].toString());
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
QVariant CAiAlarmTreeItem::aigetDataByColumn(int column)
|
||||
{
|
||||
if(m_aialarmPtr != NULL)
|
||||
{
|
||||
switch (column) {
|
||||
case TIME:
|
||||
m_data[0] = QDateTime::fromMSecsSinceEpoch(m_aialarmPtr->time_stamp).toString("yyyy-MM-dd hh:mm:ss.zzz");
|
||||
return m_data[0];
|
||||
case PRIORITY:
|
||||
m_data[1] = CAlarmBaseData::instance()->queryPriorityDesc(m_aialarmPtr->priority);
|
||||
return m_data[1];
|
||||
case LOCATION:
|
||||
m_data[2] = CAlarmMsgManage::instance()->queryLocationDesc(m_aialarmPtr->uuid_base64);
|
||||
return m_data[2];
|
||||
case REGION:
|
||||
m_data[3] ="-";
|
||||
return m_data[3];
|
||||
case TYPE:
|
||||
m_data[4] ="-";
|
||||
return "-";
|
||||
case STATUS:
|
||||
m_data[5] ="-";
|
||||
return "-";
|
||||
case RETURNSTATUS:
|
||||
m_data[6] ="-";
|
||||
return "-";
|
||||
case CONFIRM:
|
||||
m_data[7] = QString("%1/%2").arg(getConfirm()).arg(m_child.size());
|
||||
return m_data[7];
|
||||
case CONTENT:
|
||||
m_data[8] = m_aialarmPtr->content;
|
||||
return m_data[8];
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant CAiAlarmTreeItem::getDataByColumn(int column)
|
||||
{
|
||||
if(m_alarmPtr != NULL)
|
||||
{
|
||||
switch (column) {
|
||||
case TIME:
|
||||
{
|
||||
m_data[0] = QDateTime::fromMSecsSinceEpoch(m_alarmPtr->time_stamp).toString("yyyy-MM-dd hh:mm:ss.zzz");
|
||||
return m_data[0];
|
||||
}
|
||||
case PRIORITY:
|
||||
{
|
||||
m_data[1] = CAlarmBaseData::instance()->queryPriorityDesc(m_alarmPtr->priority);
|
||||
return m_data[1];
|
||||
}
|
||||
case LOCATION:
|
||||
{
|
||||
m_data[2] = CAlarmBaseData::instance()->queryLocationDesc(m_alarmPtr->location_id);
|
||||
return m_data[2];
|
||||
}
|
||||
case REGION:
|
||||
{
|
||||
m_data[3] = CAlarmBaseData::instance()->queryRegionDesc(m_alarmPtr->region_id);
|
||||
return m_data[3];
|
||||
}
|
||||
case TYPE:
|
||||
{
|
||||
m_data[4] = CAlarmBaseData::instance()->queryAlarmTypeDesc(m_alarmPtr->alm_type);
|
||||
return m_data[4];
|
||||
}
|
||||
case STATUS:
|
||||
{
|
||||
m_data[5] = CAlarmBaseData::instance()->queryAlarmStatusDesc(m_alarmPtr->alm_status);
|
||||
return m_data[5];
|
||||
}
|
||||
case RETURNSTATUS:
|
||||
{
|
||||
if(E_ALS_ALARM == m_alarmPtr->logic_state || E_ALS_ALARM_CFM == m_alarmPtr->logic_state ||
|
||||
E_ALS_ALARM_DEL == m_alarmPtr->logic_state || E_ALS_ALARM_CFM_DEL == m_alarmPtr->logic_state) //未复归
|
||||
{
|
||||
m_data[6] = QObject::tr("未复归");
|
||||
return m_data[6];
|
||||
}
|
||||
else if(E_ALS_RETURN == m_alarmPtr->logic_state || E_ALS_RETURN_CFM == m_alarmPtr->logic_state ||
|
||||
E_ALS_RETURN_DEL == m_alarmPtr->logic_state || E_ALS_RETURN_CFM_DEL == m_alarmPtr->logic_state)
|
||||
{
|
||||
m_data[6] = QObject::tr("已复归");
|
||||
return m_data[6];
|
||||
}else
|
||||
{
|
||||
m_data[6] = QObject::tr("-");
|
||||
return m_data[6];
|
||||
}
|
||||
}
|
||||
case CONFIRM:
|
||||
{
|
||||
if(E_ALS_ALARM == m_alarmPtr->logic_state || E_ALS_RETURN == m_alarmPtr->logic_state
|
||||
|| E_ALS_ALARM_DEL == m_alarmPtr->logic_state || E_ALS_RETURN_DEL == m_alarmPtr->logic_state) //< 未确认
|
||||
{
|
||||
m_data[7] = QObject::tr("未确认");
|
||||
return m_data[7];
|
||||
}
|
||||
else if(E_ALS_ALARM_CFM == m_alarmPtr->logic_state || E_ALS_RETURN_CFM == m_alarmPtr->logic_state ||
|
||||
E_ALS_ALARM_CFM_DEL == m_alarmPtr->logic_state || E_ALS_RETURN_CFM_DEL == m_alarmPtr->logic_state ||
|
||||
ALS_EVT_ONLY == m_alarmPtr->logic_state)
|
||||
{
|
||||
m_data[7] = QObject::tr("已确认");
|
||||
return m_data[7];
|
||||
}
|
||||
}
|
||||
case CONTENT:
|
||||
{
|
||||
m_data[8] = m_alarmPtr->content;
|
||||
return m_data[8];
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int CAiAlarmTreeItem::getConfirm()
|
||||
{
|
||||
int size = 0;
|
||||
QList<CAiAlarmTreeItem*>::iterator it = m_child.begin();
|
||||
while (it != m_child.end()) {
|
||||
AlarmMsgPtr ptr;
|
||||
if((*it)->getPtr(ptr))
|
||||
{
|
||||
if(ptr->logic_state == E_ALS_ALARM_CFM || ptr->logic_state == E_ALS_RETURN_CFM
|
||||
|| ptr->logic_state == E_ALS_ALARM_CFM_DEL || ptr->logic_state == E_ALS_RETURN_CFM_DEL || ptr->logic_state == ALS_EVT_ONLY)
|
||||
{
|
||||
size++;
|
||||
}
|
||||
}
|
||||
it++;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
81
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmTreeItem.h
Normal file
81
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmTreeItem.h
Normal file
@ -0,0 +1,81 @@
|
||||
#ifndef CAIALARMTREEITEM_H
|
||||
#define CAIALARMTREEITEM_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QVariant>
|
||||
#include "CAlarmMsgManage.h"
|
||||
enum E_ItemDataRole
|
||||
{
|
||||
E_IfAiFlag =0x0101, //< 是否智能告警
|
||||
E_DisplayRole =0x0102,
|
||||
E_UserRole = 0x0103, //< uuid
|
||||
E_CheckStateRole = 0x0104
|
||||
};
|
||||
enum ColumnField
|
||||
{
|
||||
TIME = 0,
|
||||
PRIORITY,
|
||||
LOCATION,
|
||||
REGION,
|
||||
TYPE,
|
||||
STATUS,
|
||||
RETURNSTATUS,
|
||||
CONFIRM,
|
||||
CONTENT
|
||||
};
|
||||
class CAiAlarmTreeItem
|
||||
{
|
||||
public:
|
||||
explicit CAiAlarmTreeItem(const QVector<QVariant> &data,CAiAlarmTreeItem *parent = Q_NULLPTR);
|
||||
~CAiAlarmTreeItem();
|
||||
|
||||
CAiAlarmTreeItem *child(int row);
|
||||
CAiAlarmTreeItem *parent();
|
||||
|
||||
int childCount() const;
|
||||
int columnCount() const;
|
||||
//返回行数
|
||||
int childNumber() const;
|
||||
QVariant data(int column,int role = E_DisplayRole);
|
||||
bool setData(int column,const QVariant &value,int role);
|
||||
bool setPtr(AlarmMsgPtr ptr);
|
||||
bool setAiPtr(AiAlarmMsgPtr aiPtr);
|
||||
bool insertChildren(int position, int count, int columns);
|
||||
bool removeChildren(int position, int count, int columns);
|
||||
bool isAi();
|
||||
|
||||
//若确定是原始告警可以直接使用
|
||||
AlarmMsgPtr ptr();
|
||||
bool getPtr(AlarmMsgPtr &ptr);
|
||||
bool getAiPtr(AiAlarmMsgPtr &aiPtr);
|
||||
QList<AlarmMsgPtr> getChildAlarmPtr();
|
||||
|
||||
int index(const QString uuid);
|
||||
|
||||
bool lessThan(CAiAlarmTreeItem *info, E_ALARM_SORTKEY sortkey = E_SORT_PRIORITY);
|
||||
bool moreThan(CAiAlarmTreeItem* info, E_ALARM_SORTKEY sortkey = E_SORT_PRIORITY);
|
||||
|
||||
QList<CAiAlarmTreeItem*> getChild();
|
||||
void setChild(QList<CAiAlarmTreeItem*> itemList);
|
||||
|
||||
QList<CAiAlarmTreeItem*> getChildItemList();
|
||||
|
||||
QVector<QString> getContent();
|
||||
private:
|
||||
QVariant aigetDataByColumn(int column);
|
||||
QVariant getDataByColumn(int column);
|
||||
int getConfirm();
|
||||
private:
|
||||
QString m_uuid;
|
||||
bool m_bIsAi;
|
||||
QList<CAiAlarmTreeItem*> m_child;
|
||||
CAiAlarmTreeItem *m_parent;
|
||||
|
||||
QVector<QVariant> m_data;
|
||||
AlarmMsgPtr m_alarmPtr;
|
||||
AiAlarmMsgPtr m_aialarmPtr;
|
||||
|
||||
//Qt::CheckState m_checkState;
|
||||
};
|
||||
|
||||
#endif // CAIALARMTREEITEM_H
|
||||
1134
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmTreeModel.cpp
Normal file
1134
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmTreeModel.cpp
Normal file
File diff suppressed because it is too large
Load Diff
310
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmTreeModel.h
Normal file
310
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmTreeModel.h
Normal file
@ -0,0 +1,310 @@
|
||||
#ifndef CAIALARMTREEMODEL_H
|
||||
#define CAIALARMTREEMODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <CAiAlarmTreeItem.h>
|
||||
#include <QTimer>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QMap>
|
||||
|
||||
typedef QPair<int, QList<CAiAlarmTreeItem*> > PAIRLISTAIALARMINFO;
|
||||
class CAiAlarmTreeModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CAiAlarmTreeModel(QObject *parent = nullptr);
|
||||
~CAiAlarmTreeModel();
|
||||
|
||||
void initialize();
|
||||
// Header:
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
// Basic functionality:
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const override;
|
||||
QModelIndex parent(const QModelIndex &index) const override;
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||
// Add data:
|
||||
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
|
||||
// Remove data:
|
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
|
||||
void setModel();
|
||||
|
||||
CAiAlarmTreeItem *getItem(const QModelIndex &index) const;
|
||||
|
||||
CAiAlarmTreeItem *getItem() const;
|
||||
|
||||
void initFilter();
|
||||
|
||||
void setFilter(const bool &isLevelFilterEnable, const QList<int> &levelFilter,
|
||||
const bool &isStationFilterEnable, const QList<int> &stationFilter,
|
||||
const bool &isRegionFilterEnable, const QList<int> ®ionFilter,
|
||||
const bool &isStatusFilterEnable, const QList<int> &statusFilter,
|
||||
const bool &isDeviceTypeFilter = false, const QString &subSystem = QString(), const QString &deviceType = QString(),
|
||||
const bool &isKeywordFilterEnable = false, const QString &keyword = QString(),
|
||||
const bool &timeFilterEnable = false, const QDateTime &startTime = QDateTime(),
|
||||
const QDateTime &endTime = QDateTime(), const bool &confirmFilterEnable = false, const bool &isConfirm = false,
|
||||
const bool &returnFilterEnable = false, const bool &isReturn =false);
|
||||
|
||||
/**
|
||||
* @brief addDeviceGroupFilter 添加设备组过滤
|
||||
* @param deviceGroup 设备组名称
|
||||
*/
|
||||
void addDeviceGroupFilter(const QString &deviceGroup);
|
||||
void removeDeviceGroupFilter();
|
||||
/**
|
||||
* @brief removeDeviceGroupFilter 移除设备组过滤
|
||||
* @param deviceGroup 设备组名称
|
||||
*/
|
||||
void removeDeviceGroupFilter(const QString &deviceGroup);
|
||||
|
||||
/**
|
||||
* @brief conditionFilter 判断原始告警是否需要展示
|
||||
* @param ptr 原始告警智能指针
|
||||
* @return 允许返回true 否则返回false
|
||||
*/
|
||||
bool conditionFilter(const AlarmMsgPtr ptr);
|
||||
|
||||
/**
|
||||
* @brief conditionAiFilter 判断智能告警是否需要展示,并获取需要展示的原始告警 (当almList的size大于0时,则认为智能告警需要展示)
|
||||
* @param ptr 智能告警智能指针
|
||||
* @param almList 获取的要展示的原始告警智能指针
|
||||
*/
|
||||
void conditionAiFilter(const AiAlarmMsgPtr ptr, QList<AlarmMsgPtr> &almList);
|
||||
|
||||
/**
|
||||
* @brief sortAlm 对原始告警进行排序(此处是用在对智能告警二级节点上的原始告警排序)
|
||||
* @param almList 需要排序的原始告警列表
|
||||
*/
|
||||
void sortAlm(QList<AlarmMsgPtr> &almList);
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief setPriorityFilter 设置优先级过滤
|
||||
* @param isCheck 是否设置
|
||||
* @param priorityFilter 过滤的条件集合
|
||||
*/
|
||||
void setPriorityFilter(bool &isCheck, QList<int> &priorityFilter);
|
||||
|
||||
/**
|
||||
* @brief setLocationFilter 设置车站过滤
|
||||
* @param isCheck 是否设置
|
||||
* @param locationFilter 过滤的条件集合
|
||||
*/
|
||||
void setLocationFilter(bool &isCheck, QList<int> &locationFilter);
|
||||
|
||||
/**
|
||||
* @brief setAlarmTypeFilter 设置告警类型过滤
|
||||
* @param isCheck 是否设置
|
||||
* @param alarmTypeFilter 过滤的条件集合
|
||||
* @param other 是否包含其他条件(此处只得是不属于下拉框中的告警类型)
|
||||
*/
|
||||
void setAlarmTypeFilter(bool &isCheck, QList<int> &alarmTypeFilter, bool &other);
|
||||
|
||||
/**
|
||||
* @brief setAlarmTimeFilter 设置告警时间过滤
|
||||
* @param isCheck 是否设置
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
*/
|
||||
void setAlarmTimeFilter(bool &isCheck, QDate &startTime,QDate &endTime);
|
||||
|
||||
/**
|
||||
* @brief setAlarmTimeFilter 设置是否需要时间过滤 (此处用法是告警大窗日历中点击取消调用)
|
||||
* @param isCheck 是否设置
|
||||
*/
|
||||
void setAlarmTimeFilter(bool &isCheck);
|
||||
|
||||
/**
|
||||
* @brief insertAlarmMsg 插入原始告警
|
||||
* @param infoList 原始告警智能指针集合
|
||||
*/
|
||||
void insertAlarmMsg(const QList<AlarmMsgPtr> &infoList);
|
||||
|
||||
/**
|
||||
* @brief insertAlarmMsg 插入智能告警
|
||||
* @param info 智能告警智能指针
|
||||
* @param almList 智能告警包含的原始告警智能指针集合
|
||||
*/
|
||||
void insertAlarmMsg(const AiAlarmMsgPtr info, QList<AlarmMsgPtr> &almList);
|
||||
|
||||
/**
|
||||
* @brief getShowNum 获取显示的原始告警数量
|
||||
* @return 原始告警数量
|
||||
*/
|
||||
int getShowNum();
|
||||
|
||||
/**
|
||||
* @brief getShowAi 获取显示的智能告警数量
|
||||
* @return 智能告警数量
|
||||
*/
|
||||
int getShowAi();
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
* @brief slotMsgArrived 接收原始告警
|
||||
* @param listMsg 原始告警智能智能集合
|
||||
*/
|
||||
void slotMsgArrived(QList<AlarmMsgPtr> listMsg);
|
||||
|
||||
/**
|
||||
* @brief slotAiMsgAdd 接收智能告警
|
||||
* @param aimsgList 智能告警智能指针集合
|
||||
*/
|
||||
void slotAiMsgAdd(const QList<AiAlarmMsgPtr> &aimsgList);
|
||||
|
||||
/**
|
||||
* @brief slotAiMsgRemove 接收要移除的智能告警
|
||||
* @param uuidList 要移除的智能告警uuid集合
|
||||
*/
|
||||
void slotAiMsgRemove(const QList<QString> &uuidList);
|
||||
|
||||
/**
|
||||
* @brief slotMsgRefresh 重新获取告警数据
|
||||
*/
|
||||
void slotMsgRefresh();
|
||||
|
||||
/**
|
||||
* @brief sortColumn 根据列排序
|
||||
* @param column 列号
|
||||
* @param order 升序或者降序
|
||||
*/
|
||||
void sortColumn(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
||||
|
||||
/**
|
||||
* @brief slotMsgRemove 接收要删除的原始告警(一级节点上的)
|
||||
* @param deluuid 原始告警uuid
|
||||
*/
|
||||
void slotMsgRemove(const QVector<QString> deluuid);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief setModelData 设置模型
|
||||
* @param parent 父节点指针
|
||||
*/
|
||||
void setModelData(CAiAlarmTreeItem *parent);
|
||||
|
||||
/**
|
||||
* @brief sort 排序
|
||||
*/
|
||||
void sort();
|
||||
|
||||
/**
|
||||
* @brief qucikSort 快排
|
||||
* @param list 需要排序的集合
|
||||
* @param start 开始下标
|
||||
* @param last 结束下标
|
||||
*/
|
||||
void qucikSort(QList<CAiAlarmTreeItem*> &list, int start, int last);
|
||||
|
||||
/**
|
||||
* @brief partitionAscendingOrder 升序排序
|
||||
* @param list 排序列表
|
||||
* @param start 开始位置
|
||||
* @param last 结束位置
|
||||
* @return 排序位置
|
||||
*/
|
||||
int partitionAscendingOrder(QList<CAiAlarmTreeItem*> &list, int start, int last);
|
||||
|
||||
/**
|
||||
* @brief partitionAscendingOrder 降序排序
|
||||
* @param list 排序列表
|
||||
* @param start 开始位置
|
||||
* @param last 结束位置
|
||||
* @return 排序位置
|
||||
*/
|
||||
int partitionDescendingOrder(QList<CAiAlarmTreeItem*> &list, int start, int last);
|
||||
|
||||
/**
|
||||
* @brief qucikSort 快排
|
||||
* @param list 需要排序的集合
|
||||
* @param start 开始下标
|
||||
* @param last 结束下标
|
||||
*/
|
||||
void qucikSort(QList<AlarmMsgPtr> &list, int start, int last);
|
||||
|
||||
/**
|
||||
* @brief partitionAscendingOrder 升序排序
|
||||
* @param list 排序列表
|
||||
* @param start 开始位置
|
||||
* @param last 结束位置
|
||||
* @return 排序位置
|
||||
*/
|
||||
int partitionAscendingOrder(QList<AlarmMsgPtr> &list, int start, int last);
|
||||
|
||||
/**
|
||||
* @brief partitionAscendingOrder 降序排序
|
||||
* @param list 排序列表
|
||||
* @param start 开始位置
|
||||
* @param last 结束位置
|
||||
* @return 排序位置
|
||||
*/
|
||||
int partitionDescendingOrder(QList<AlarmMsgPtr> &list, int start, int last);
|
||||
|
||||
/**
|
||||
* @brief calcLeft 计算位置
|
||||
* @param info 智能告警智能指针
|
||||
* @return 排序位置
|
||||
*/
|
||||
int calcLeft(const AiAlarmMsgPtr &info);
|
||||
|
||||
/**
|
||||
* @brief calcLeft 计算位置
|
||||
* @param info 原始告警智能指针
|
||||
* @return 排序位置
|
||||
*/
|
||||
int calcLeft(const AlarmMsgPtr &info);
|
||||
|
||||
private:
|
||||
|
||||
CAiAlarmTreeItem *m_root;
|
||||
QVector<QVariant> m_header;
|
||||
QList<Qt::AlignmentFlag> m_listHorAlignmentFlags; //< 水平对齐方式
|
||||
|
||||
//< Filter
|
||||
bool m_isLevelFilterEnable; //是否按告警级别过滤
|
||||
QList<int> m_levelFilter; //告警级别过滤
|
||||
bool m_isLocationFilterEnable; //是否按车站过滤
|
||||
QList<int> m_locationFilter; //车站过滤
|
||||
bool m_isRegionFilterEnable; //是否按责任区过滤
|
||||
QList<int> m_regionFilter; //责任区过滤
|
||||
bool m_isStatusFilterEnable; //是否按告警类型过滤
|
||||
QList<int> m_statusFilter; //告警类型过滤(所有的要过滤告警状态--如果其他状态没有被勾选,则与下面的内容相同)
|
||||
QList<int> m_statusFilter2; //告警类型过滤(显示在过滤窗中的告警状态)
|
||||
bool m_isDeviceTypeFileter; //设备类型过滤
|
||||
QString m_subSystem; //子系统
|
||||
QString m_deviceType; //设备类型
|
||||
bool m_isKeywordEnable; //关键字过滤
|
||||
QString m_keyowrd; //关键字
|
||||
bool m_timeFilterEnable; //是否根据时间过滤
|
||||
QDateTime m_startTime; //起始时间
|
||||
QDateTime m_endTime; //终止时间
|
||||
bool m_confirmFilterEnable; //是否根据状态确认过滤
|
||||
bool m_isConfirm; //状态是否确认
|
||||
|
||||
bool m_returnFilterEnable; //是否根据复归状态过滤
|
||||
bool m_isReturn; //是否已复归
|
||||
|
||||
|
||||
QSet<QString> m_deviceFilter; //< 设备过滤
|
||||
QSet<QString> m_pointFilter; //标签过滤
|
||||
QSet<QString> m_deviceGroupFilter; //<设备组过滤
|
||||
|
||||
E_ALARM_SORTKEY m_sortKey; //排序规则
|
||||
Qt::SortOrder m_order;
|
||||
|
||||
int m_nShowNum;
|
||||
int m_nShowAiNum;
|
||||
|
||||
};
|
||||
|
||||
#endif // CAIALARMTREEMODEL_H
|
||||
25
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmTreeView.cpp
Normal file
25
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmTreeView.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "CAiAlarmTreeView.h"
|
||||
#include <QHeaderView>
|
||||
#include <QScrollBar>
|
||||
#include <QStyleFactory>
|
||||
CAiAlarmTreeView::CAiAlarmTreeView(QWidget *parent)
|
||||
:QTreeView(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CAiAlarmTreeView::initialize()
|
||||
{
|
||||
setSortingEnabled(true);
|
||||
setAlternatingRowColors(true);
|
||||
header()->setDefaultAlignment(Qt::AlignCenter);
|
||||
header()->setSectionResizeMode(QHeaderView::Interactive);
|
||||
//header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
header()->setStretchLastSection(true);
|
||||
//header()->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
//header()->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
//setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
//setHorizontalScrollMode(ScrollPerPixel);
|
||||
setUniformRowHeights(true);
|
||||
}
|
||||
15
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmTreeView.h
Normal file
15
product/src/gui/plugin/AlarmWidget_pad/CAiAlarmTreeView.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef CAIALARMTREEVIEW_H
|
||||
#define CAIALARMTREEVIEW_H
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
class CAiAlarmTreeView : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CAiAlarmTreeView(QWidget *parent = Q_NULLPTR);
|
||||
|
||||
void initialize();
|
||||
};
|
||||
|
||||
#endif // CAIALARMTREEVIEW_H
|
||||
659
product/src/gui/plugin/AlarmWidget_pad/CAlarmBaseData.cpp
Normal file
659
product/src/gui/plugin/AlarmWidget_pad/CAlarmBaseData.cpp
Normal file
@ -0,0 +1,659 @@
|
||||
#include "CAlarmBaseData.h"
|
||||
#include "perm_mng_api/PermMngApi.h"
|
||||
#include "CAlarmCommon.h"
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include "boost/property_tree/xml_parser.hpp"
|
||||
#include "boost/typeof/typeof.hpp"
|
||||
#include "boost/filesystem.hpp"
|
||||
#include "pub_utility_api/FileUtil.h"
|
||||
#include "pub_utility_api/CharUtil.h"
|
||||
|
||||
using namespace iot_public;
|
||||
using namespace std;
|
||||
|
||||
CAlarmBaseData *CAlarmBaseData::pInstance = NULL;
|
||||
CAlarmBaseData *CAlarmBaseData::instance()
|
||||
{
|
||||
if(pInstance == NULL)
|
||||
{
|
||||
pInstance = new CAlarmBaseData();
|
||||
}
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CAlarmBaseData::~CAlarmBaseData()
|
||||
{
|
||||
LOGDEBUG("~CAlarmBaseData()");
|
||||
}
|
||||
|
||||
void CAlarmBaseData::destory()
|
||||
{
|
||||
if(m_rtdbAccess)
|
||||
{
|
||||
delete m_rtdbAccess;
|
||||
}
|
||||
|
||||
m_rtdbAccess = Q_NULLPTR;
|
||||
pInstance = NULL;
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
void CAlarmBaseData::initData()
|
||||
{
|
||||
loadPermInfo();
|
||||
loadAlarmInfoConfig();
|
||||
}
|
||||
|
||||
QString CAlarmBaseData::queryPriorityDesc(int id)
|
||||
{
|
||||
return m_priorityDescriptionMap.value(id,QString());
|
||||
}
|
||||
|
||||
QString CAlarmBaseData::queryLocationDesc(int id)
|
||||
{
|
||||
return m_locationDescriptionMap.value(id,QString());
|
||||
}
|
||||
|
||||
QString CAlarmBaseData::queryRegionDesc(int id)
|
||||
{
|
||||
return m_regionDescriptionMap.value(id,QString());
|
||||
}
|
||||
|
||||
QString CAlarmBaseData::queryAlarmTypeDesc(int id)
|
||||
{
|
||||
return m_alarmTypeDescriptionMap.value(id,QString());
|
||||
}
|
||||
|
||||
QString CAlarmBaseData::queryAlarmStatusDesc(int id)
|
||||
{
|
||||
return m_alarmStatusDescriptionMap.value(id,QString());
|
||||
}
|
||||
|
||||
int CAlarmBaseData::queryDevTypeByDesc(QString &desc)
|
||||
{
|
||||
return m_deviceTypeDescriptionMap.key(desc);
|
||||
}
|
||||
|
||||
QList<QString> CAlarmBaseData::getDevGroupTagList()
|
||||
{
|
||||
return m_deviceGroupDescriptionMap.keys();
|
||||
}
|
||||
|
||||
QMap<int, QString> CAlarmBaseData::getAlarmOtherStatus()
|
||||
{
|
||||
return m_alarmOtherStatusDescriptionMap;
|
||||
}
|
||||
|
||||
CAlarmBaseData::CAlarmBaseData(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_rtdbAccess(Q_NULLPTR)
|
||||
{
|
||||
m_rtdbAccess = new iot_dbms::CRdbAccess();
|
||||
m_pWriteDb = new iot_dbms::CDbApi(DB_CONN_MODEL_WRITE);
|
||||
m_pWriteDb->open();
|
||||
createSysInfoInstance(m_ptrSysInfo);
|
||||
initData();
|
||||
}
|
||||
|
||||
void CAlarmBaseData::loadPermInfo()
|
||||
{
|
||||
iot_service::CPermMngApiPtr permMngPtr = iot_service::getPermMngInstance("base");
|
||||
m_listPermLocationId.clear();
|
||||
m_listPermRegionId.clear();
|
||||
if(permMngPtr != NULL)
|
||||
{
|
||||
permMngPtr->PermDllInit();
|
||||
std::vector <int> vecRegionId;
|
||||
std::vector <int> vecLocationId;
|
||||
if(PERM_NORMAL == permMngPtr->GetSpeFunc(FUNC_SPE_ALARM_VIEW, vecRegionId, vecLocationId))
|
||||
{
|
||||
std::vector <int>::iterator location = vecLocationId.begin();
|
||||
while (location != vecLocationId.end())
|
||||
{
|
||||
m_listPermLocationId.append(*location++);
|
||||
}
|
||||
std::vector <int>::iterator region = vecRegionId.begin();
|
||||
while (region != vecRegionId.end())
|
||||
{
|
||||
m_listPermRegionId.append(*region++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmBaseData::loadAlarmInfoConfig()
|
||||
{
|
||||
loadPriorityDescription();
|
||||
loadLocationDescription();
|
||||
loadRegionDescription();
|
||||
loadAlarmTypeDescription();
|
||||
loadAlarmStatusDescription();
|
||||
loadDeviceTypeDescription();
|
||||
loadDeviceGroupDescription();
|
||||
loadAlarmShowStatusDescription();
|
||||
loadAlarmOtherStatusDescription();
|
||||
}
|
||||
|
||||
int CAlarmBaseData::queryDomainIdByLocId(int loactionId)
|
||||
{
|
||||
if(m_ptrSysInfo)
|
||||
{
|
||||
SLocationInfo stLocationInfo;
|
||||
if(iotSuccess == m_ptrSysInfo->getLocationInfoById(loactionId, stLocationInfo))
|
||||
{
|
||||
return stLocationInfo.nDomainId;
|
||||
}
|
||||
}
|
||||
return CN_InvalidDomainId;
|
||||
}
|
||||
|
||||
bool CAlarmBaseData::queryAllPointDevGroup(int nDomainId, int nSubsystemId, const QString &strDevg, QList<QString> &pointList)
|
||||
{
|
||||
if(!m_ptrSysInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SAppInfo stAppInfo;
|
||||
if(iotSuccess != m_ptrSysInfo->getAppInfoBySubsystemId(nSubsystemId, stAppInfo))
|
||||
{
|
||||
LOGERROR("queryAllPointDevGroup 获取应用ID失败");
|
||||
return false;
|
||||
}
|
||||
iot_dbms::CRdbNetApi rdbNetApi;
|
||||
rdbNetApi.connect(nDomainId, stAppInfo.nId);
|
||||
|
||||
//< 查询所有设备
|
||||
QList<QString> devList;
|
||||
if(!queryAllDeviceDevGroup(rdbNetApi, strDevg, devList))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//< 查询所有测点
|
||||
for(int n(0); n<devList.length(); n++)
|
||||
{
|
||||
if(!queryAllPointDevice(rdbNetApi, devList[n], "analog", pointList))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!queryAllPointDevice(rdbNetApi, devList[n], "digital", pointList))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!queryAllPointDevice(rdbNetApi, devList[n], "accuml", pointList))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!queryAllPointDevice(rdbNetApi, devList[n], "mix", pointList))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QMap<int, QString> CAlarmBaseData::getPriorityMap()
|
||||
{
|
||||
return m_priorityDescriptionMap;
|
||||
}
|
||||
|
||||
QMap<int, QString> CAlarmBaseData::getPermPriorityMap()
|
||||
{
|
||||
return m_priorityPermDescriptionMap;
|
||||
}
|
||||
|
||||
QMap<int, QString> CAlarmBaseData::getPriorityOrderMap()
|
||||
{
|
||||
return m_priorityOrderDescriptionMap;
|
||||
}
|
||||
|
||||
QMap<int, QString> CAlarmBaseData::getPermLocationMap()
|
||||
{
|
||||
return m_locationPermDescriptionMap;
|
||||
}
|
||||
|
||||
QMap<int, QString> CAlarmBaseData::getPermRegionMap()
|
||||
{
|
||||
return m_regionPermDescriptionMap;
|
||||
}
|
||||
|
||||
QMap<int, QString> CAlarmBaseData::getAlarmShowStatusMap()
|
||||
{
|
||||
return m_alarmShowStatusDescriptionMap;
|
||||
}
|
||||
|
||||
QMap<int, QVector<int> > CAlarmBaseData::getAreaLocMap()
|
||||
{
|
||||
return m_areaLocMap;
|
||||
}
|
||||
|
||||
QMap<int, SAreaInfo> CAlarmBaseData::getAreaInfoMap()
|
||||
{
|
||||
return m_areaInfoMap;
|
||||
}
|
||||
|
||||
QList<int> CAlarmBaseData::getPermLocationIdList()
|
||||
{
|
||||
return m_listPermLocationId;
|
||||
}
|
||||
|
||||
QList<int> CAlarmBaseData::getPermRegionIdList()
|
||||
{
|
||||
return m_listPermRegionId;
|
||||
}
|
||||
|
||||
QList<int> CAlarmBaseData::getPermLocationOrder()
|
||||
{
|
||||
return m_listPermLocationOrder;
|
||||
}
|
||||
|
||||
QString CAlarmBaseData::getPermLocationDesc(const int &locationId)
|
||||
{
|
||||
return m_locationPermDescriptionMap.value(locationId);
|
||||
}
|
||||
|
||||
void CAlarmBaseData::loadPriorityDescription()
|
||||
{
|
||||
if(m_rtdbAccess->open("base", "alarm_level_define"))
|
||||
{
|
||||
m_priorityDescriptionMap.clear();
|
||||
m_priorityOrderDescriptionMap.clear();
|
||||
m_priorityPermDescriptionMap.clear();
|
||||
iot_dbms::CTableLockGuard locker(*m_rtdbAccess);
|
||||
iot_dbms::CRdbQueryResult result;
|
||||
std::vector<std::string> columns;
|
||||
columns.push_back("priority_id");
|
||||
columns.push_back("priority_order");
|
||||
columns.push_back("priority_name");
|
||||
|
||||
if(m_rtdbAccess->select(result, columns))
|
||||
{
|
||||
for(int nIndex(0); nIndex < result.getRecordCount(); nIndex++)
|
||||
{
|
||||
iot_dbms::CVarType key;
|
||||
iot_dbms::CVarType order;
|
||||
iot_dbms::CVarType value;
|
||||
result.getColumnValue(nIndex, 0, key);
|
||||
result.getColumnValue(nIndex, 1, order);
|
||||
result.getColumnValue(nIndex, 2, value);
|
||||
if(key.toInt() != 0 )
|
||||
{
|
||||
m_priorityPermDescriptionMap[key.toInt()] = QString::fromStdString(value.toStdString());
|
||||
}
|
||||
m_priorityDescriptionMap[key.toInt()] = QString::fromStdString(value.toStdString());
|
||||
m_priorityOrderDescriptionMap[order.toInt()] = QString::fromStdString(value.toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmBaseData::loadLocationDescription()
|
||||
{
|
||||
m_areaInfoMap.clear();
|
||||
m_areaLocMap.clear();
|
||||
if(m_rtdbAccess->open("base", "sys_model_location_info"))
|
||||
{
|
||||
m_locationDescriptionMap.clear();
|
||||
m_locationPermDescriptionMap.clear();
|
||||
m_listPermLocationOrder.clear();
|
||||
iot_dbms::CTableLockGuard locker(*m_rtdbAccess);
|
||||
iot_dbms::CRdbQueryResult result;
|
||||
std::vector<std::string> columns;
|
||||
columns.push_back("location_id");
|
||||
columns.push_back("description");
|
||||
columns.push_back("tag_name");
|
||||
columns.push_back("location_type");
|
||||
columns.push_back("plocation_id");
|
||||
std::string sOrderColumn = "location_no";
|
||||
|
||||
if(m_rtdbAccess->select(result, columns, sOrderColumn))
|
||||
{
|
||||
for(int nIndex(0); nIndex < result.getRecordCount(); nIndex++)
|
||||
{
|
||||
iot_dbms::CVarType id;
|
||||
iot_dbms::CVarType desc;
|
||||
iot_dbms::CVarType tag;
|
||||
iot_dbms::CVarType type;
|
||||
iot_dbms::CVarType pid;
|
||||
result.getColumnValue(nIndex, 0, id);
|
||||
result.getColumnValue(nIndex, 1, desc);
|
||||
result.getColumnValue(nIndex, 2, tag);
|
||||
result.getColumnValue(nIndex, 3, type);
|
||||
result.getColumnValue(nIndex, 4, pid);
|
||||
|
||||
if(m_listPermLocationId.contains(id.toInt()))
|
||||
{
|
||||
m_locationPermDescriptionMap[id.toInt()] = QString::fromStdString(desc.toStdString());
|
||||
m_listPermLocationOrder.push_back(id.toInt());
|
||||
}
|
||||
m_locationDescriptionMap[id.toInt()] = QString::fromStdString(desc.toStdString());
|
||||
|
||||
|
||||
SAreaInfo info;
|
||||
info.nId =id.toInt();
|
||||
info.stTag =QString::fromStdString(tag.toStdString());
|
||||
info.stDes =QString::fromStdString(desc.toStdString());
|
||||
if(type.toInt() != (int)E_LOCATION_NODE)
|
||||
{
|
||||
info.eType = E_LOCATION_AREA;
|
||||
}else
|
||||
{
|
||||
info.eType = E_LOCATION_NODE;
|
||||
}
|
||||
|
||||
info.nPareaId =pid.toInt();
|
||||
m_areaInfoMap[info.nId] = info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QMap<int,SAreaInfo>::iterator it= m_areaInfoMap.begin();
|
||||
while (it != m_areaInfoMap.end()) {
|
||||
if(m_listPermLocationId.contains(it.key()))
|
||||
{
|
||||
if(it.value().eType == (int)E_LOCATION_NODE)
|
||||
{
|
||||
QMap<int,QVector<int> >::iterator pos = m_areaLocMap.find(it.value().nPareaId);
|
||||
if(pos == m_areaLocMap.end())
|
||||
{
|
||||
QVector<int> locVec;
|
||||
locVec.append(it.value().nId);
|
||||
m_areaLocMap.insert(it.value().nPareaId,locVec);
|
||||
}else
|
||||
{
|
||||
QVector<int> &locVec = pos.value();
|
||||
locVec.append(it.value().nId);
|
||||
}
|
||||
}else
|
||||
{
|
||||
QMap<int,QVector<int> >::iterator pos = m_areaLocMap.find(it.key());
|
||||
if(pos == m_areaLocMap.end())
|
||||
{
|
||||
QVector<int> locVec;
|
||||
locVec.append(it.value().nId);
|
||||
m_areaLocMap.insert(it.key(),locVec);
|
||||
}else
|
||||
{
|
||||
QVector<int> &locVec = pos.value();
|
||||
locVec.append(it.value().nId);
|
||||
}
|
||||
}
|
||||
}
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmBaseData::loadRegionDescription()
|
||||
{
|
||||
if(m_rtdbAccess->open("base", "region_info"))
|
||||
{
|
||||
m_regionDescriptionMap.clear();
|
||||
m_regionPermDescriptionMap.clear();
|
||||
iot_dbms::CTableLockGuard locker(*m_rtdbAccess);
|
||||
iot_dbms::CRdbQueryResult result;
|
||||
std::vector<std::string> columns;
|
||||
columns.push_back("region_id");
|
||||
columns.push_back("description");
|
||||
|
||||
if(m_rtdbAccess->select(result, columns))
|
||||
{
|
||||
for(int nIndex(0); nIndex < result.getRecordCount(); nIndex++)
|
||||
{
|
||||
iot_dbms::CVarType key;
|
||||
iot_dbms::CVarType value;
|
||||
result.getColumnValue(nIndex, 0, key);
|
||||
result.getColumnValue(nIndex, 1, value);
|
||||
if(m_listPermRegionId.contains(key.toInt()))
|
||||
{
|
||||
m_regionPermDescriptionMap[key.toInt()] = QString::fromStdString(value.toStdString());
|
||||
}
|
||||
m_regionDescriptionMap[key.toInt()] = QString::fromStdString(value.toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
m_regionPermDescriptionMap[-1] = "无责任区";//QString();
|
||||
m_regionDescriptionMap[-1] = QString();
|
||||
}
|
||||
|
||||
void CAlarmBaseData::loadAlarmTypeDescription()
|
||||
{
|
||||
if(m_rtdbAccess->open("base", "alarm_type_define"))
|
||||
{
|
||||
m_alarmTypeDescriptionMap.clear();
|
||||
iot_dbms::CTableLockGuard locker(*m_rtdbAccess);
|
||||
iot_dbms::CRdbQueryResult result;
|
||||
std::vector<std::string> columns;
|
||||
columns.push_back("type_id");
|
||||
columns.push_back("type_name");
|
||||
|
||||
if(m_rtdbAccess->select(result, columns))
|
||||
{
|
||||
for(int nIndex(0); nIndex < result.getRecordCount(); nIndex++)
|
||||
{
|
||||
iot_dbms::CVarType key;
|
||||
iot_dbms::CVarType value;
|
||||
result.getColumnValue(nIndex, 0, key);
|
||||
result.getColumnValue(nIndex, 1, value);
|
||||
m_alarmTypeDescriptionMap[key.toInt()] = QString::fromStdString(value.toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmBaseData::loadAlarmStatusDescription()
|
||||
{
|
||||
if(m_rtdbAccess->open("base", "alarm_status_define"))
|
||||
{
|
||||
m_alarmStatusDescriptionMap.clear();
|
||||
iot_dbms::CTableLockGuard locker(*m_rtdbAccess);
|
||||
iot_dbms::CRdbQueryResult result;
|
||||
std::vector<std::string> columns;
|
||||
columns.push_back("status_value");
|
||||
columns.push_back("display_name");
|
||||
|
||||
if(m_rtdbAccess->select(result, columns))
|
||||
{
|
||||
for(int nIndex(0); nIndex < result.getRecordCount(); nIndex++)
|
||||
{
|
||||
iot_dbms::CVarType key;
|
||||
iot_dbms::CVarType value;
|
||||
result.getColumnValue(nIndex, 0, key);
|
||||
result.getColumnValue(nIndex, 1, value);
|
||||
m_alarmStatusDescriptionMap[key.toInt()] = QString::fromStdString(value.toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmBaseData::loadDeviceTypeDescription()
|
||||
{
|
||||
if(m_rtdbAccess->open("base", "dev_type_def"))
|
||||
{
|
||||
m_deviceTypeDescriptionMap.clear();
|
||||
iot_dbms::CTableLockGuard locker(*m_rtdbAccess);
|
||||
iot_dbms::CRdbQueryResult result;
|
||||
std::vector<std::string> columns;
|
||||
columns.push_back("dev_type_id");
|
||||
columns.push_back("description");
|
||||
|
||||
if(m_rtdbAccess->select(result, columns))
|
||||
{
|
||||
for(int nIndex(0); nIndex < result.getRecordCount(); nIndex++)
|
||||
{
|
||||
iot_dbms::CVarType key;
|
||||
iot_dbms::CVarType value;
|
||||
result.getColumnValue(nIndex, 0, key);
|
||||
result.getColumnValue(nIndex, 1, value);
|
||||
m_deviceTypeDescriptionMap[key.toInt()] = QString::fromStdString(value.toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmBaseData::loadDeviceGroupDescription()
|
||||
{
|
||||
if(m_rtdbAccess->open("base", "dev_group"))
|
||||
{
|
||||
m_deviceGroupDescriptionMap.clear();
|
||||
iot_dbms::CTableLockGuard locker(*m_rtdbAccess);
|
||||
iot_dbms::CRdbQueryResult result;
|
||||
std::vector<std::string> columns;
|
||||
columns.push_back("tag_name");
|
||||
columns.push_back("description");
|
||||
|
||||
if(m_rtdbAccess->select(result, columns))
|
||||
{
|
||||
for(int nIndex(0); nIndex < result.getRecordCount(); nIndex++)
|
||||
{
|
||||
iot_dbms::CVarType key;
|
||||
iot_dbms::CVarType value;
|
||||
result.getColumnValue(nIndex, 0, key);
|
||||
result.getColumnValue(nIndex, 1, value);
|
||||
m_deviceGroupDescriptionMap[QString::fromStdString(key.toStdString())] = QString::fromStdString(value.toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmBaseData::loadAlarmShowStatusDescription()
|
||||
{
|
||||
const std::string strConfFullPath = iot_public::CFileUtil::getPathOfCfgFile("alarmStatus.xml");
|
||||
boost::property_tree::ptree pt;
|
||||
namespace xml = boost::property_tree::xml_parser;
|
||||
m_alarmShowStatusDescriptionMap.clear();
|
||||
try
|
||||
{
|
||||
xml::read_xml(strConfFullPath, pt, xml::no_comments);
|
||||
BOOST_AUTO(module, pt.get_child("root"));
|
||||
for (BOOST_AUTO(pModuleIter, module.begin()); pModuleIter != module.end(); ++pModuleIter)
|
||||
{
|
||||
boost::property_tree::ptree ptParam = pModuleIter->second;
|
||||
for (BOOST_AUTO(pParamIter, ptParam.begin()); pParamIter != ptParam.end(); ++pParamIter)
|
||||
{
|
||||
if (pParamIter->first == "param")
|
||||
{
|
||||
std::string strKey = pParamIter->second.get<std::string>("<xmlattr>.key");
|
||||
//string strValue = pParamIter->second.get<string>("<xmlattr>.value");
|
||||
if(StringToInt(strKey) != OTHERSTATUS)
|
||||
{
|
||||
m_alarmShowStatusDescriptionMap[StringToInt(strKey)] = m_alarmStatusDescriptionMap[StringToInt(strKey)];
|
||||
}else
|
||||
{
|
||||
m_alarmShowStatusDescriptionMap[StringToInt(strKey)] = tr("其他");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception &ex)
|
||||
{
|
||||
LOGERROR("解析配置文件[%s]失败.Msg=[%s]", strConfFullPath.c_str(), ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmBaseData::loadAlarmOtherStatusDescription()
|
||||
{
|
||||
const std::string strConfFullPath = iot_public::CFileUtil::getPathOfCfgFile("alarmOther.xml");
|
||||
boost::property_tree::ptree pt;
|
||||
namespace xml = boost::property_tree::xml_parser;
|
||||
m_alarmOtherStatusDescriptionMap.clear();
|
||||
try
|
||||
{
|
||||
xml::read_xml(strConfFullPath, pt, xml::no_comments);
|
||||
BOOST_AUTO(module, pt.get_child("root"));
|
||||
for (BOOST_AUTO(pModuleIter, module.begin()); pModuleIter != module.end(); ++pModuleIter)
|
||||
{
|
||||
boost::property_tree::ptree ptParam = pModuleIter->second;
|
||||
for (BOOST_AUTO(pParamIter, ptParam.begin()); pParamIter != ptParam.end(); ++pParamIter)
|
||||
{
|
||||
if (pParamIter->first == "param")
|
||||
{
|
||||
string strKey = pParamIter->second.get<string>("<xmlattr>.key");
|
||||
//string strValue = pParamIter->second.get<string>("<xmlattr>.value");
|
||||
m_alarmOtherStatusDescriptionMap[StringToInt(strKey)] = m_alarmStatusDescriptionMap[StringToInt(strKey)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception &ex)
|
||||
{
|
||||
LOGERROR("解析配置文件[%s]失败.Msg=[%s]", strConfFullPath.c_str(), ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
bool CAlarmBaseData::queryAllDeviceDevGroup(iot_dbms::CRdbNetApi &rdbNetApi, const QString &devg, QList<QString> &devList)
|
||||
{
|
||||
//< 查询设备组所有设备
|
||||
iot_idl::RdbQuery msgQuery;
|
||||
msgQuery.set_strtablename("dev_info");
|
||||
msgQuery.add_strselectcolnamearr("tag_name");
|
||||
iot_idl::RdbCondition *pCondtion = msgQuery.add_msgcondition();
|
||||
pCondtion->set_enlogic(iot_idl::ENConditionLogic::enumCondAnd);
|
||||
pCondtion->set_enrelation(iot_idl::ENConditionRelation::enumCondEqual);
|
||||
pCondtion->set_strcolumnname("group_tag_name");
|
||||
iot_idl::SVariable *pCondValue = pCondtion->mutable_msgvalue();
|
||||
pCondValue->set_edatatype(iot_idl::DataType::CN_DATATYPE_STRING);
|
||||
pCondValue->set_strvalue(devg.toStdString());
|
||||
|
||||
iot_idl::RdbRet retMsg;
|
||||
bool bRet;
|
||||
bRet = rdbNetApi.query(msgQuery, retMsg);
|
||||
if (false == bRet)
|
||||
{
|
||||
LOGERROR("queryAllDeviceDevGroup,未查询到条目");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < retMsg.msgrecord_size(); ++i)
|
||||
{
|
||||
if(retMsg.msgrecord(i).msgvaluearray_size() != 1)
|
||||
{
|
||||
LOGERROR("queryAllDeviceDevGroup,查询结果不对");
|
||||
continue;
|
||||
}
|
||||
|
||||
devList.append(QString::fromStdString(retMsg.msgrecord(i).msgvaluearray(0).strvalue()));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAlarmBaseData::queryAllPointDevice(iot_dbms::CRdbNetApi &rdbNetApi, const QString &device, const QString &table, QList<QString> &pointList)
|
||||
{
|
||||
iot_idl::RdbQuery msgQuery;
|
||||
msgQuery.set_strtablename(table.toStdString().c_str());
|
||||
msgQuery.add_strselectcolnamearr("tag_name");
|
||||
iot_idl::RdbCondition *pCondtion = msgQuery.add_msgcondition();
|
||||
pCondtion->set_enlogic(iot_idl::ENConditionLogic::enumCondAnd);
|
||||
pCondtion->set_enrelation(iot_idl::ENConditionRelation::enumCondEqual);
|
||||
pCondtion->set_strcolumnname("device");
|
||||
iot_idl::SVariable *pCondValue = pCondtion->mutable_msgvalue();
|
||||
pCondValue->set_edatatype(iot_idl::DataType::CN_DATATYPE_STRING);
|
||||
pCondValue->set_strvalue(device.toStdString().c_str());
|
||||
|
||||
iot_idl::RdbRet retMsg;
|
||||
bool bRet;
|
||||
bRet = rdbNetApi.query(msgQuery, retMsg);
|
||||
if (false == bRet)
|
||||
{
|
||||
LOGERROR("queryAllPointDevice,未查询到条目");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < retMsg.msgrecord_size(); ++i)
|
||||
{
|
||||
if(retMsg.msgrecord(i).msgvaluearray_size() != 1)
|
||||
{
|
||||
LOGERROR("queryAllPointDevice,查询结果不对");
|
||||
continue;
|
||||
}
|
||||
|
||||
pointList.append(QString("%1.%2.%3").arg(table)
|
||||
.arg(QString::fromStdString(retMsg.msgrecord(i).msgvaluearray(0).strvalue()))
|
||||
.arg("value"));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
197
product/src/gui/plugin/AlarmWidget_pad/CAlarmBaseData.h
Normal file
197
product/src/gui/plugin/AlarmWidget_pad/CAlarmBaseData.h
Normal file
@ -0,0 +1,197 @@
|
||||
#ifndef CALARMBASEDATA_H
|
||||
#define CALARMBASEDATA_H
|
||||
|
||||
#include <QObject>
|
||||
#include "dbms/rdb_api/CRdbAccess.h"
|
||||
#include "dbms/rdb_net_api/CRdbNetApi.h"
|
||||
#include "dbms/db_api_ex/CDbApi.h"
|
||||
#include "pub_sysinfo_api/SysInfoApi.h"
|
||||
#include <QMap>
|
||||
#include "CAlarmCommon.h"
|
||||
#include <QVector>
|
||||
|
||||
class CAlarmBaseData : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static CAlarmBaseData * instance();
|
||||
|
||||
~CAlarmBaseData();
|
||||
|
||||
void destory();
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief initData 初始化数据
|
||||
*/
|
||||
void initData();
|
||||
/**
|
||||
* @brief queryPriorityDesc 根据id查询优先级描述
|
||||
* @param id 优先级id
|
||||
* @return 优先级描述
|
||||
*/
|
||||
QString queryPriorityDesc(int id);
|
||||
/**
|
||||
* @brief queryLocationDesc 根据位置id查询位置描述
|
||||
* @param id 位置id
|
||||
* @return 位置描述
|
||||
*/
|
||||
QString queryLocationDesc(int id);
|
||||
/**
|
||||
* @brief queryRegionDesc 根据责任区id查询责任区描述
|
||||
* @param id 责任区id
|
||||
* @return 责任区描述
|
||||
*/
|
||||
QString queryRegionDesc(int id);
|
||||
/**
|
||||
* @brief queryAlarmTypeDesc 根据告警类型id查询告警类型描述
|
||||
* @param id 告警类型id
|
||||
* @return 告警类型描述
|
||||
*/
|
||||
QString queryAlarmTypeDesc(int id);
|
||||
/**
|
||||
* @brief queryAlarmStatusDesc 根据告警状态id查询告警状态描述
|
||||
* @param id 告警状态id
|
||||
* @return 告警状态描述
|
||||
*/
|
||||
QString queryAlarmStatusDesc(int id);
|
||||
/**
|
||||
* @brief queryDevTypeByDesc 根据设备类型描述查询设备类型id
|
||||
* @param desc 设备描述
|
||||
* @return 设备id
|
||||
*/
|
||||
int queryDevTypeByDesc(QString &desc);
|
||||
|
||||
QList<QString> getDevGroupTagList();
|
||||
/**
|
||||
* @brief getAlarmOtherStatus 获取其他告警状态集合
|
||||
* @return 其他告警状态集合
|
||||
*/
|
||||
QMap<int, QString> getAlarmOtherStatus();
|
||||
/**
|
||||
* @brief loadAlarmInfoConfig 加载告警配置信息
|
||||
*/
|
||||
void loadAlarmInfoConfig();
|
||||
|
||||
/**
|
||||
* @brief queryDomainIdByLocId 通过车站ID得到域ID
|
||||
* @param loactionId
|
||||
*/
|
||||
int queryDomainIdByLocId(int loactionId);
|
||||
|
||||
bool queryAllPointDevGroup(int nDomainId, int nSubsystemId, const QString &strDevg, QList<QString> &pointList);
|
||||
|
||||
QMap<int, QString> getPriorityMap();
|
||||
|
||||
QMap<int, QString> getPermPriorityMap();
|
||||
|
||||
QMap<int, QString> getPriorityOrderMap();
|
||||
|
||||
QMap<int, QString> getPermLocationMap();
|
||||
|
||||
QMap<int, QString> getPermRegionMap();
|
||||
|
||||
QMap<int, QString> getAlarmShowStatusMap();
|
||||
|
||||
QMap<int,QVector<int> > getAreaLocMap();
|
||||
|
||||
QMap<int,SAreaInfo> getAreaInfoMap();
|
||||
|
||||
QList<int> getPermLocationIdList();
|
||||
|
||||
QList<int> getPermRegionIdList();
|
||||
|
||||
QList<int> getPermLocationOrder();
|
||||
|
||||
QString getPermLocationDesc(const int &locationId);
|
||||
|
||||
private:
|
||||
explicit CAlarmBaseData(QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief loadPermInfo 加载权限
|
||||
*/
|
||||
void loadPermInfo();
|
||||
|
||||
/**
|
||||
* @brief loadPriorityDescription 加载优先级描述
|
||||
*/
|
||||
void loadPriorityDescription();
|
||||
/**
|
||||
* @brief loadLocationDescription 加载位置描述
|
||||
*/
|
||||
void loadLocationDescription();
|
||||
/**
|
||||
* @brief loadRegionDescription 加载责任区描述
|
||||
*/
|
||||
void loadRegionDescription();
|
||||
/**
|
||||
* @brief loadAlarmTypeDescription 加载告警类型
|
||||
*/
|
||||
void loadAlarmTypeDescription();
|
||||
/**
|
||||
* @brief loadAlarmStatusDescription 加载告警状态描述
|
||||
*/
|
||||
void loadAlarmStatusDescription();
|
||||
/**
|
||||
* @brief loadDeviceTypeDescription 加载设备类型描述
|
||||
*/
|
||||
void loadDeviceTypeDescription();
|
||||
/**
|
||||
* @brief loadDeviceGroupDescription 加载设备组描述
|
||||
*/
|
||||
void loadDeviceGroupDescription();
|
||||
/**
|
||||
* @brief loadAlarmShowStatusDescription 加载需要显示在告警窗下拉框中的告警状态描述
|
||||
*/
|
||||
void loadAlarmShowStatusDescription();
|
||||
/**
|
||||
* @brief loadAlarmOtherStatusDescription 加载其他告警状态描述
|
||||
*/
|
||||
void loadAlarmOtherStatusDescription();
|
||||
|
||||
/**
|
||||
* @brief queryAllDeviceDevGroup 查询设备组下所有设备
|
||||
* @param rdbNetApi
|
||||
* @param devg
|
||||
*/
|
||||
bool queryAllDeviceDevGroup(iot_dbms::CRdbNetApi &rdbNetApi, const QString &devg, QList<QString> &devList);
|
||||
/**
|
||||
* @brief queryAllPointDevice 查询表中设备下所有测点
|
||||
* @param rdbNetApi
|
||||
* @param device
|
||||
* @param table
|
||||
* @param pointList "digital.station.G01_dlq.r.value"
|
||||
* @return
|
||||
*/
|
||||
bool queryAllPointDevice(iot_dbms::CRdbNetApi &rdbNetApi, const QString &device, const QString &table, QList<QString> &pointList);
|
||||
|
||||
private:
|
||||
static CAlarmBaseData * pInstance;
|
||||
iot_dbms::CRdbAccess * m_rtdbAccess;
|
||||
iot_dbms::CDbApi *m_pWriteDb;
|
||||
iot_public::CSysInfoInterfacePtr m_ptrSysInfo;
|
||||
QList<int> m_listPermLocationId; //< 原始告警车站权限
|
||||
QList<int> m_listPermRegionId; //< 原始告警责任区权限
|
||||
QList<int> m_listPermLocationOrder; //< 有权限的loaction_id: 按location_no排序
|
||||
|
||||
QMap<int, QString> m_priorityDescriptionMap;
|
||||
QMap<int, QString> m_priorityPermDescriptionMap;
|
||||
QMap<int, QString> m_priorityOrderDescriptionMap;
|
||||
QMap<int, QString> m_locationDescriptionMap;
|
||||
QMap<int, QString> m_regionDescriptionMap;
|
||||
QMap<int, QString> m_locationPermDescriptionMap; //有权限的
|
||||
QMap<int, QString> m_regionPermDescriptionMap; //有权限的
|
||||
QMap<int, QString> m_alarmTypeDescriptionMap;
|
||||
QMap<int, QString> m_alarmStatusDescriptionMap;
|
||||
QMap<int, QString> m_deviceTypeDescriptionMap;
|
||||
QMap<QString, QString> m_deviceGroupDescriptionMap;
|
||||
QMap<int, QString> m_alarmShowStatusDescriptionMap;
|
||||
QMap<int, QString> m_alarmOtherStatusDescriptionMap;
|
||||
|
||||
|
||||
QMap<int,SAreaInfo> m_areaInfoMap; //区域信息
|
||||
|
||||
QMap<int,QVector<int> > m_areaLocMap; //区域映射
|
||||
};
|
||||
|
||||
#endif // CALARMBASEDATA_H
|
||||
@ -0,0 +1,6 @@
|
||||
#include "CAlarmColorInfo.h"
|
||||
|
||||
CAlarmColorInfo::CAlarmColorInfo()
|
||||
{
|
||||
|
||||
}
|
||||
21
product/src/gui/plugin/AlarmWidget_pad/CAlarmColorInfo.h
Normal file
21
product/src/gui/plugin/AlarmWidget_pad/CAlarmColorInfo.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef CALARMCOLORINFO_H
|
||||
#define CALARMCOLORINFO_H
|
||||
|
||||
#include <QColor>
|
||||
|
||||
class CAlarmColorInfo
|
||||
{
|
||||
public:
|
||||
CAlarmColorInfo();
|
||||
|
||||
int priority;
|
||||
QColor background_color;
|
||||
QColor alternating_color;
|
||||
QColor confirm_color;
|
||||
QColor active_text_color;
|
||||
QColor resume_text_color;
|
||||
QColor confirm_text_color;
|
||||
QString icon;
|
||||
};
|
||||
|
||||
#endif // CALARMCOLORINFO_H
|
||||
129
product/src/gui/plugin/AlarmWidget_pad/CAlarmColorWidget.cpp
Normal file
129
product/src/gui/plugin/AlarmWidget_pad/CAlarmColorWidget.cpp
Normal file
@ -0,0 +1,129 @@
|
||||
#include "CAlarmColorWidget.h"
|
||||
#include "ui_CAlarmColorWidget.h"
|
||||
#include <QColorDialog>
|
||||
#include "CAlarmSetMng.h"
|
||||
|
||||
CAlarmColorWidget::CAlarmColorWidget(CAlarmColorInfo *info, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::CAlarmColorWidget),
|
||||
m_info(info)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->label_2->installEventFilter(this);
|
||||
ui->label_4->installEventFilter(this);
|
||||
ui->label_6->installEventFilter(this);
|
||||
ui->label_9->installEventFilter(this);
|
||||
|
||||
QString title = CAlarmSetMng::instance()->getPriorityDescByOrder(m_info->priority);
|
||||
title+=":";
|
||||
ui->label_7->setText(title);
|
||||
updateColorLabel(ui->label_2, m_info->active_text_color);
|
||||
updateColorLabel(ui->label_4, m_info->resume_text_color);
|
||||
updateColorLabel(ui->label_6, m_info->confirm_text_color);
|
||||
updateColorLabel(ui->label_9, m_info->alternating_color);
|
||||
}
|
||||
|
||||
CAlarmColorWidget::~CAlarmColorWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool CAlarmColorWidget::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if(watched == ui->label_2)
|
||||
{
|
||||
if(event->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
if(mouseEvent->button() == Qt::LeftButton)
|
||||
{
|
||||
chooseColor(ui->label_2, &(m_info->active_text_color));
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else if(watched == ui->label_4)
|
||||
{
|
||||
if(event->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
if(mouseEvent->button() == Qt::LeftButton)
|
||||
{
|
||||
chooseColor(ui->label_4, &(m_info->resume_text_color));
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else if(watched == ui->label_6)
|
||||
{
|
||||
if(event->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
if(mouseEvent->button() == Qt::LeftButton)
|
||||
{
|
||||
chooseColor(ui->label_6, &(m_info->confirm_text_color));
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else if(watched == ui->label_9)
|
||||
{
|
||||
if(event->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
if(mouseEvent->button() == Qt::LeftButton)
|
||||
{
|
||||
chooseColor(ui->label_9, &(m_info->alternating_color));
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else
|
||||
{
|
||||
return QWidget::eventFilter(watched,event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CAlarmColorWidget::chooseColor(QLabel *label, QColor *color)
|
||||
{
|
||||
QColor newColor=QColorDialog::getColor(*color,this);
|
||||
if(newColor.isValid()){
|
||||
*color=newColor;
|
||||
updateColorLabel(label,*color);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmColorWidget::updateColorLabel(QLabel *label, const QColor &color)
|
||||
{
|
||||
label->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(color.red()).arg(color.green()).arg(color.blue()));
|
||||
if(label == ui->label_2)
|
||||
{
|
||||
m_info->active_text_color = color;
|
||||
}else if(label == ui->label_4)
|
||||
{
|
||||
m_info->resume_text_color = color;
|
||||
}else if(label == ui->label_6)
|
||||
{
|
||||
m_info->confirm_text_color = color;
|
||||
}else if(label == ui->label_9)
|
||||
{
|
||||
m_info->alternating_color = color;
|
||||
}
|
||||
}
|
||||
31
product/src/gui/plugin/AlarmWidget_pad/CAlarmColorWidget.h
Normal file
31
product/src/gui/plugin/AlarmWidget_pad/CAlarmColorWidget.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef CALARMCOLORWIDGET_H
|
||||
#define CALARMCOLORWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include "CAlarmColorInfo.h"
|
||||
#include <QMouseEvent>
|
||||
|
||||
namespace Ui {
|
||||
class CAlarmColorWidget;
|
||||
}
|
||||
|
||||
class CAlarmColorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CAlarmColorWidget(CAlarmColorInfo *info,QWidget *parent = 0);
|
||||
~CAlarmColorWidget();
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
private:
|
||||
void chooseColor(QLabel *label, QColor *color);
|
||||
void updateColorLabel(QLabel *label, const QColor &color);
|
||||
|
||||
private:
|
||||
Ui::CAlarmColorWidget *ui;
|
||||
CAlarmColorInfo *m_info;
|
||||
};
|
||||
|
||||
#endif // CALARMCOLORWIDGET_H
|
||||
151
product/src/gui/plugin/AlarmWidget_pad/CAlarmColorWidget.ui
Normal file
151
product/src/gui/plugin/AlarmWidget_pad/CAlarmColorWidget.ui
Normal file
@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAlarmColorWidget</class>
|
||||
<widget class="QWidget" name="CAlarmColorWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>455</width>
|
||||
<height>36</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>动作颜色</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>恢复颜色</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>确认颜色</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>闪烁颜色</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
103
product/src/gui/plugin/AlarmWidget_pad/CAlarmCommon.h
Normal file
103
product/src/gui/plugin/AlarmWidget_pad/CAlarmCommon.h
Normal file
@ -0,0 +1,103 @@
|
||||
#ifndef CALARMCOMMON_H
|
||||
#define CALARMCOMMON_H
|
||||
|
||||
#include <QSharedPointer>
|
||||
class CAlarmMsgInfo;
|
||||
class CAiAlarmMsgInfo;
|
||||
|
||||
typedef QSharedPointer<CAlarmMsgInfo> AlarmMsgPtr;
|
||||
typedef QSharedPointer<CAiAlarmMsgInfo> AiAlarmMsgPtr;
|
||||
typedef QPair<int, QList<AlarmMsgPtr> > PAIRLISTALARMINFO;
|
||||
|
||||
|
||||
const QString fun_ia_edit = "FUNC_NOM_IA_EDIT"; //智能告警编辑权限
|
||||
#define FUNC_SPE_ALARM_VIEW ("FUNC_SPE_ALARM_VIEW")
|
||||
#define OPT_FUNC_SPE_OPT_OVERRIDE ("FUNC_SPE_OPT_OVERRIDE")
|
||||
|
||||
#define VIDEO_TIME 30*1000
|
||||
#define FAULT_RECORD_TIME 30*1000
|
||||
#define BUTTON_COLUMN 8 //按钮所在列
|
||||
#define ICON_COLUMN 1 //图标所在列
|
||||
const int OTHERSTATUS = 9999;
|
||||
//窗口
|
||||
enum E_Alarm_Mode
|
||||
{
|
||||
E_Alarm_Dock,
|
||||
E_Alarm_Window,
|
||||
E_Alarm_Pop
|
||||
};
|
||||
enum E_TAGNAME_TYPE
|
||||
{
|
||||
E_TAGNAME_ANA =0,
|
||||
E_TAGNAME_ACC,
|
||||
E_TAGNAME_MIX,
|
||||
E_TAGNAME_DIG,
|
||||
E_TAGNAME_ERROR
|
||||
};
|
||||
//排序
|
||||
enum E_ALARM_SORTKEY
|
||||
{
|
||||
E_SORT_TIME=0, //< 时间戳
|
||||
E_SORT_PRIORITY , //< 优先级
|
||||
E_SORT_LOCATION, //< 车站
|
||||
E_SORT_REGION, //< 责任区
|
||||
E_SORT_TYPE, //< 告警类型
|
||||
E_SORT_ALM_STATE, //< 告警状态
|
||||
E_SORT_STYLE, //< 复归状态
|
||||
E_SORT_LOGICSTATE, //< 逻辑状态
|
||||
E_SORT_CONTENT //< 告警内容
|
||||
};
|
||||
//告警动作
|
||||
enum E_ALARM_SOUND_VOICE
|
||||
{
|
||||
E_ALARM_SOUND = 0, //声音告警
|
||||
E_ALARM_VOICE //语音告警
|
||||
};
|
||||
//告警方式
|
||||
enum E_ALARM_STYLE{
|
||||
E_STYLE_REPEAT_X = -2,
|
||||
E_STYLE_REPEAT = -1,
|
||||
E_STYLE_NO_ALARM = 0
|
||||
};
|
||||
|
||||
enum E_LOCATION_TYPE
|
||||
{
|
||||
E_LOCATION_NODE = 0,
|
||||
E_LOCATION_AREA
|
||||
};
|
||||
|
||||
struct SAiConfirm
|
||||
{
|
||||
int nConfirm;
|
||||
int nTotal;
|
||||
SAiConfirm() {
|
||||
nConfirm = 0;
|
||||
nTotal = 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct SAreaInfo
|
||||
{
|
||||
int nId;
|
||||
QString stTag;
|
||||
QString stDes;
|
||||
E_LOCATION_TYPE eType;
|
||||
int nPareaId;
|
||||
SAreaInfo() {
|
||||
nId = -1;
|
||||
stTag = QString();
|
||||
stDes = QString();
|
||||
eType = E_LOCATION_NODE;
|
||||
nPareaId = -1;
|
||||
}
|
||||
};
|
||||
|
||||
struct SDevGroupInfo{
|
||||
QString tag_name;
|
||||
QString description;
|
||||
int domain;
|
||||
int location;
|
||||
int sub_system;
|
||||
int region;
|
||||
};
|
||||
#endif // CALARMCOMMON_H
|
||||
356
product/src/gui/plugin/AlarmWidget_pad/CAlarmDataCollect.cpp
Normal file
356
product/src/gui/plugin/AlarmWidget_pad/CAlarmDataCollect.cpp
Normal file
@ -0,0 +1,356 @@
|
||||
#include "CAlarmDataCollect.h"
|
||||
#include <QDateTime>
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include "CAlarmMsgManage.h"
|
||||
#include <QDebug>
|
||||
#include "CAiAlarmDataCollect.h"
|
||||
#include "alarm_server_api/AlarmCommonDef.h"
|
||||
|
||||
using namespace iot_service;
|
||||
using namespace iot_dbms;
|
||||
CAlarmDataCollect * CAlarmDataCollect::m_pInstance = NULL;
|
||||
|
||||
CAlarmDataCollect::CAlarmDataCollect()
|
||||
: CAlmApiForAlmClt(),
|
||||
m_referenceCount(0),
|
||||
m_bFaultRecallState(false),
|
||||
m_pAlternateTimer(Q_NULLPTR), m_rtdbAlmLvlDefTab(nullptr), m_rtdbAlmActDefTab(nullptr),
|
||||
m_bIsNeedUpdate(false),
|
||||
m_bIsNeedRemove(false), m_bIsNeedRelease(false),
|
||||
m_removeNum(0)
|
||||
{
|
||||
m_rtdbMutex = new QMutex();
|
||||
m_rtdbAccess = new iot_dbms::CRdbAccess();
|
||||
m_rtdbAccess->open("base", "alarm_level_define");
|
||||
}
|
||||
|
||||
CAlarmDataCollect::~CAlarmDataCollect()
|
||||
{
|
||||
LOGINFO("CAlarmDataCollect::~CAlarmDataCollect()");
|
||||
qDebug() << "~CAlarmDataCollect()";
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::refrence()
|
||||
{
|
||||
m_referenceCount++;
|
||||
}
|
||||
|
||||
CAlarmDataCollect *CAlarmDataCollect::instance()
|
||||
{
|
||||
if(NULL == m_pInstance)
|
||||
{
|
||||
m_pInstance = new CAlarmDataCollect();
|
||||
}
|
||||
return m_pInstance;
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::initialize()
|
||||
{
|
||||
resumeThread();
|
||||
if(!m_pAlternateTimer)
|
||||
{
|
||||
m_pAlternateTimer = new QTimer();
|
||||
m_pAlternateTimer->setInterval(1000);
|
||||
connect(m_pAlternateTimer, &QTimer::timeout, this, &CAlarmDataCollect::slotAlarmStateChanged);
|
||||
connect(this, &CAlarmDataCollect::sigTimerShot, this, &CAlarmDataCollect::slotTimerShot, Qt::QueuedConnection);
|
||||
}
|
||||
if(!m_bFaultRecallState)
|
||||
{
|
||||
emit sigTimerShot(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::release()
|
||||
{
|
||||
LOGINFO("CAlarmDataCollect::release()");
|
||||
emit sigTimerShot(false);
|
||||
suspendThread(true);
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
m_bIsNeedUpdate = false;
|
||||
m_bIsNeedRemove = false;
|
||||
m_removeNum = 0;
|
||||
}
|
||||
|
||||
|
||||
int CAlarmDataCollect::getRefrenceCount()
|
||||
{
|
||||
return m_referenceCount;
|
||||
}
|
||||
|
||||
bool CAlarmDataCollect::isFaultRecallState()
|
||||
{
|
||||
return m_bFaultRecallState;
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::destory()
|
||||
{
|
||||
LOGINFO("退出时:CAlarmDataCollect::destory()打开窗口的个数m_referenceCount:[%d]",m_referenceCount);
|
||||
if(--m_referenceCount > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
slotTimerShot(false);
|
||||
suspendThread();
|
||||
{
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
if(Q_NULLPTR != m_pAlternateTimer)
|
||||
{
|
||||
m_pAlternateTimer->stop();
|
||||
m_pAlternateTimer->deleteLater();
|
||||
}
|
||||
m_pAlternateTimer = Q_NULLPTR;
|
||||
m_bIsNeedUpdate = false;
|
||||
m_bIsNeedRemove = false;
|
||||
}
|
||||
delete m_rtdbMutex;
|
||||
delete m_rtdbAccess;
|
||||
m_pInstance = NULL;
|
||||
delete this;
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::slotTimerShot(const bool start)
|
||||
{
|
||||
if(m_pAlternateTimer)
|
||||
{
|
||||
if(start)
|
||||
{
|
||||
m_pAlternateTimer->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pAlternateTimer->stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::slotSwitchFaultRecallState(bool bFaultRecallState)
|
||||
{
|
||||
m_bFaultRecallState = bFaultRecallState;
|
||||
release();
|
||||
m_pInstance->reinit(m_bFaultRecallState);
|
||||
CAiAlarmDataCollect::instance()->slotSwitchFaultRecallState(bFaultRecallState);
|
||||
emit sigAlarmStateChanged(0, 0);
|
||||
emit sigMsgRefresh();
|
||||
|
||||
initialize();
|
||||
CAiAlarmDataCollect::instance()->initialize();
|
||||
|
||||
emit sigAlarmOperateEnable(!m_bFaultRecallState);
|
||||
}
|
||||
|
||||
bool CAlarmDataCollect::requestCfmAlm(iot_idl::SAlmCltCfmAlm &objCfmAlm)
|
||||
{
|
||||
return iot_service::CAlmApiForAlmClt::requestCfmAlm(objCfmAlm);
|
||||
}
|
||||
|
||||
bool CAlarmDataCollect::requestDelAlm(iot_idl::SAlmCltDelAlm &objDelAlm)
|
||||
{
|
||||
return iot_service::CAlmApiForAlmClt::requestDelAlm(objDelAlm);
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::handleAllAlmMsg(int domainId, iot_idl::SAlmCltAddAlm &objAllAlm)
|
||||
{
|
||||
if(!m_referenceCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LOGINFO("========== AlarmDataCollect handleAllAlmMsg ==========");
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
//< 清空该域缓存
|
||||
|
||||
CAlarmMsgManage::instance()->removeAlarmMsgByDomainID(domainId);
|
||||
|
||||
//< 构建告警
|
||||
int nAlarmCount = objAllAlm.alm_info_size();
|
||||
QList<AlarmMsgPtr> almList;
|
||||
for(int nAddMsgIndex(0); nAddMsgIndex < nAlarmCount; nAddMsgIndex++)
|
||||
{
|
||||
iot_idl::SAlmInfoToAlmClt msg = objAllAlm.alm_info(nAddMsgIndex);
|
||||
AlarmMsgPtr alm(new CAlarmMsgInfo());
|
||||
alm->initialize(msg);
|
||||
alm->priorityOrder = queryPriorityOrder(alm->priority);
|
||||
//是否需要视频告警
|
||||
int alarmAction = queryAlarmAction(alm->priority);
|
||||
if(!alm->m_camera.isEmpty() && !alm->m_preset.isEmpty() && (ALM_ACT_VIDEO_ALM == (alarmAction & ALM_ACT_VIDEO_ALM)))
|
||||
{
|
||||
alm->m_needVideoAlm = true;
|
||||
}else
|
||||
{
|
||||
alm->m_needVideoAlm = false;
|
||||
}
|
||||
almList.append(alm);
|
||||
}
|
||||
CAlarmMsgManage::instance()->addAlarmMsg(almList);
|
||||
emit sigDevTreeUpdate();
|
||||
emit sigMsgRefresh();
|
||||
|
||||
LOGDEBUG("handleAllAlmMsg END[%d] ",nAlarmCount);
|
||||
if(m_bFaultRecallState)
|
||||
{
|
||||
int total = CAlarmMsgManage::instance()->getAlarmTotalSize();
|
||||
int unConfirm = CAlarmMsgManage::instance()->getUnConfirmSize();
|
||||
emit sigAlarmStateChanged(total, unConfirm);
|
||||
emit sigUpdateAlarmView();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::handleAddAlmMsg(iot_idl::SAlmCltAddAlm &objAddAlm)
|
||||
{
|
||||
if(!m_referenceCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LOGINFO("========== AlarmDataCollect handleAddAlmMsg ==========");
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
//< 构建告警
|
||||
int nAlarmCount = objAddAlm.alm_info_size();
|
||||
QList<AlarmMsgPtr> almList;
|
||||
for(int nAddMsgIndex(0); nAddMsgIndex < nAlarmCount; nAddMsgIndex++)
|
||||
{
|
||||
iot_idl::SAlmInfoToAlmClt msg = objAddAlm.alm_info(nAddMsgIndex);
|
||||
AlarmMsgPtr alm(new CAlarmMsgInfo());
|
||||
alm->initialize(msg);
|
||||
alm->priorityOrder = queryPriorityOrder(alm->priority);
|
||||
//是否需要视频告警
|
||||
int alarmAction = queryAlarmAction(alm->priority);
|
||||
if(!alm->m_camera.isEmpty() && !alm->m_preset.isEmpty() && (ALM_ACT_VIDEO_ALM == (alarmAction & ALM_ACT_VIDEO_ALM)))
|
||||
{
|
||||
alm->m_needVideoAlm = true;
|
||||
}else
|
||||
{
|
||||
alm->m_needVideoAlm = false;
|
||||
}
|
||||
almList.append(alm);
|
||||
}
|
||||
CAlarmMsgManage::instance()->addAlarmToAllInfo(almList);
|
||||
CAlarmMsgManage::instance()->addAlarmCacheMsg(almList);
|
||||
LOGINFO("handleAddAlmMsg END[%d] ",nAlarmCount);
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::handleCfmAlmMsg(iot_idl::SAlmCltCfmAlm &objCfmAlm)
|
||||
{
|
||||
if(!m_referenceCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LOGINFO("========== AlarmDataCollect handleCfmAlmMsg ==========");
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
QList<QString> uuidList;
|
||||
int nAlarmCount = objCfmAlm.uuid_base64_size();
|
||||
for(int nCfmMsgIndex(0); nCfmMsgIndex < nAlarmCount; nCfmMsgIndex++)
|
||||
{
|
||||
QString uuid = QString::fromStdString(objCfmAlm.uuid_base64(nCfmMsgIndex));
|
||||
uuidList.append(uuid);
|
||||
}
|
||||
CAlarmMsgManage::instance()->confirmAlarmMsg(uuidList);
|
||||
m_bIsNeedUpdate = true;
|
||||
LOGINFO("handleCfmAlmMsg END[%d] ",nAlarmCount);
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::handleDelAlmMsg(iot_idl::SAlmCltDelAlm &objDelAlm)
|
||||
{
|
||||
if(!m_referenceCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LOGINFO("========== AlarmDataCollect handleDelAlmMsg ==========");
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
QList<QString> uuidList;
|
||||
int nAlarmCount = objDelAlm.uuid_base64_size();
|
||||
for(int nDelMsgIndex(0); nDelMsgIndex < nAlarmCount; nDelMsgIndex++)
|
||||
{
|
||||
QString uuid = QString::fromStdString(objDelAlm.uuid_base64(nDelMsgIndex));
|
||||
uuidList.append(uuid);
|
||||
}
|
||||
int size = CAlarmMsgManage::instance()->removeAlarmMsg(uuidList);
|
||||
m_removeNum += size;
|
||||
m_bIsNeedRemove = true;
|
||||
LOGINFO("handleDelAlmMsg END[%d] ",nAlarmCount);
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::handleReleaseAlmMsg(iot_idl::SAlmCltReleaseAlm &objRelAlm)
|
||||
{
|
||||
if(!m_referenceCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LOGINFO("========== AlarmDataCollect handleReleaseAlmMsg ==========");
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
int nAlarmCount = objRelAlm.uuid_base64_size();
|
||||
QList<QString> uuidList;
|
||||
for(int nRelMsgIndex(0); nRelMsgIndex < nAlarmCount; nRelMsgIndex++)
|
||||
{
|
||||
QString uuid = QString::fromStdString(objRelAlm.uuid_base64(nRelMsgIndex));
|
||||
uuidList.append(uuid);
|
||||
}
|
||||
int size = CAlarmMsgManage::instance()->removeAlarmMsg(uuidList);
|
||||
m_removeNum += size;
|
||||
m_bIsNeedRemove = true;
|
||||
CAlarmMsgManage::instance()->releaseAlarmMsg(uuidList);
|
||||
LOGINFO("handleReleaseAlmMsg END[%d] ",nAlarmCount);
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::handleLinkWave2AlmMsg(iot_idl::SAlmCltLinkWave2Alm &objWave2Alm)
|
||||
{
|
||||
if(!m_referenceCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LOGINFO("========== CAlarmDataCollect handleLinkWave2AlmMsg ==========");
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
QString waveFile = QString::fromStdString(objWave2Alm.wave_file());
|
||||
int nAlarmCount = objWave2Alm.uuid_base64_size();
|
||||
QList<QString> uuidList;
|
||||
for(int nRelMsgIndex(0); nRelMsgIndex < nAlarmCount; nRelMsgIndex++)
|
||||
{
|
||||
QString uuid = QString::fromStdString(objWave2Alm.uuid_base64(nRelMsgIndex));
|
||||
uuidList.append(uuid);
|
||||
}
|
||||
CAlarmMsgManage::instance()->linkWave2AlmMsg(uuidList,waveFile);
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::refresh()
|
||||
{
|
||||
emit sigMsgRefresh();
|
||||
}
|
||||
|
||||
void CAlarmDataCollect::slotAlarmStateChanged()
|
||||
{
|
||||
QMutexLocker locker(m_rtdbMutex);
|
||||
CAlarmMsgManage::instance()->msgArrived();
|
||||
if(m_bIsNeedUpdate)
|
||||
{
|
||||
emit sigMsgConfirm();
|
||||
m_bIsNeedUpdate = false;
|
||||
}
|
||||
|
||||
if(m_bIsNeedRemove)
|
||||
{
|
||||
emit sigMsgRemove(m_removeNum);
|
||||
m_removeNum = 0;
|
||||
m_bIsNeedRemove = false;
|
||||
}
|
||||
int total = CAlarmMsgManage::instance()->getAlarmTotalSize();
|
||||
int unConfirm = CAlarmMsgManage::instance()->getUnConfirmSize();
|
||||
//CAlarmMsgManage::instance()->output();
|
||||
emit sigAlarmStateChanged(total, unConfirm);
|
||||
emit sigUpdateAlarmView();
|
||||
emit sigDevTreeUpdate();
|
||||
}
|
||||
|
||||
int CAlarmDataCollect::queryPriorityOrder(int &id)
|
||||
{
|
||||
iot_dbms::CTableLockGuard locker(*m_rtdbAccess);
|
||||
iot_dbms::CVarType value = -1000;
|
||||
m_rtdbAccess->getColumnValueByKey((void*)&id, "priority_order", value);
|
||||
return value.toInt();
|
||||
}
|
||||
|
||||
int CAlarmDataCollect::queryAlarmAction(const int &priority)
|
||||
{
|
||||
iot_dbms::CTableLockGuard locker(*m_rtdbAccess);
|
||||
iot_dbms::CVarType value;
|
||||
m_rtdbAccess->getColumnValueByKey((void*)&priority, "alarm_actions",value);
|
||||
return value.toInt();
|
||||
}
|
||||
111
product/src/gui/plugin/AlarmWidget_pad/CAlarmDataCollect.h
Normal file
111
product/src/gui/plugin/AlarmWidget_pad/CAlarmDataCollect.h
Normal file
@ -0,0 +1,111 @@
|
||||
#ifndef CALARMDATACOLLECT_H
|
||||
#define CALARMDATACOLLECT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
#include <QThread>
|
||||
#include <QMap>
|
||||
#include <QTimer>
|
||||
#include "AlarmMessage.pb.h"
|
||||
#include "CAlarmMsgInfo.h"
|
||||
#include "net_msg_bus_api/MsgBusApi.h"
|
||||
#include "dbms/rdb_api/CRdbAccess.h"
|
||||
|
||||
class CAlarmDataCollect : public QObject, public iot_service::CAlmApiForAlmClt
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static CAlarmDataCollect *instance();
|
||||
|
||||
virtual ~CAlarmDataCollect();
|
||||
|
||||
void refrence();
|
||||
|
||||
int getRefrenceCount();
|
||||
|
||||
bool isFaultRecallState();
|
||||
|
||||
virtual bool requestCfmAlm(iot_idl::SAlmCltCfmAlm &objCfmAlm);
|
||||
|
||||
virtual bool requestDelAlm(iot_idl::SAlmCltDelAlm &objDelAlm);
|
||||
|
||||
virtual void handleAllAlmMsg(int domainId, iot_idl::SAlmCltAddAlm &objAllAlm);
|
||||
|
||||
virtual void handleAddAlmMsg(iot_idl::SAlmCltAddAlm &objAddAlm);
|
||||
|
||||
virtual void handleCfmAlmMsg(iot_idl::SAlmCltCfmAlm &objCfmAlm);
|
||||
|
||||
virtual void handleDelAlmMsg(iot_idl::SAlmCltDelAlm &objDelAlm);
|
||||
|
||||
virtual void handleReleaseAlmMsg(iot_idl::SAlmCltReleaseAlm &objDelAlm);
|
||||
|
||||
virtual void handleLinkWave2AlmMsg(iot_idl::SAlmCltLinkWave2Alm &objWave2Alm);
|
||||
|
||||
void refresh();
|
||||
signals:
|
||||
//< 启停定时器
|
||||
void sigTimerShot(const bool bStop);
|
||||
|
||||
//< 定时更新,通知model刷新界面
|
||||
void sigUpdateAlarmView();
|
||||
|
||||
//< 通知所有告警插件禁用/使能告警操作
|
||||
void sigAlarmOperateEnable(const bool &bEnable);
|
||||
|
||||
//< 通知model重新拉取告警消息
|
||||
void sigMsgRefresh();
|
||||
|
||||
//< 通知model告警消息到达
|
||||
//void sigMsgArrived();
|
||||
|
||||
//< 通知model告警消息确认
|
||||
void sigMsgConfirm();
|
||||
|
||||
//< 通知model告警消息删除(原始告警 删除数量)
|
||||
void sigMsgRemove(int removeNum);
|
||||
|
||||
//< 告警数量或状态改变时触发。
|
||||
void sigAlarmStateChanged(int total, int unConfirm);
|
||||
|
||||
void sigDevTreeUpdate();
|
||||
|
||||
public slots:
|
||||
|
||||
void initialize();
|
||||
|
||||
void release();
|
||||
|
||||
void destory();
|
||||
|
||||
void slotTimerShot(const bool start);
|
||||
|
||||
void slotSwitchFaultRecallState(bool bFaultRecallState);
|
||||
|
||||
private:
|
||||
CAlarmDataCollect();
|
||||
|
||||
int queryPriorityOrder(int &id);
|
||||
int queryAlarmAction(const int &priority);
|
||||
|
||||
private slots:
|
||||
void slotAlarmStateChanged();
|
||||
|
||||
private:
|
||||
int m_referenceCount;
|
||||
bool m_bFaultRecallState; //是否处于事故追忆
|
||||
QMutex * m_rtdbMutex;
|
||||
QTimer * m_pAlternateTimer;
|
||||
iot_dbms::CRdbAccess * m_rtdbAccess;
|
||||
iot_dbms::CRdbAccess * m_rtdbAlmLvlDefTab; // 告警等级定义表
|
||||
iot_dbms::CRdbAccess * m_rtdbAlmActDefTab; // 告警动作定义表
|
||||
bool m_bIsNeedUpdate; //< 是否消息确认(每秒更新)
|
||||
bool m_bIsNeedRemove; //< 是否需要删除(每秒更新)
|
||||
bool m_bIsNeedRelease; //< 是否需要释放(每秒更新)-
|
||||
static CAlarmDataCollect * m_pInstance;
|
||||
|
||||
//1秒需要删除的条数 (在这里统计这个,原因是当删除大量数据时,一条一条删除没有重置模型效率高,此处当大于1000时,会重置模型,小于的话,则一条一条删)
|
||||
//beginRemoveRows() 和beginResetModel() 没有深入研究临界值,目前先采用1000
|
||||
int m_removeNum;
|
||||
};
|
||||
|
||||
#endif // CALARMDATACOLLECT_H
|
||||
307
product/src/gui/plugin/AlarmWidget_pad/CAlarmDelegate.cpp
Normal file
307
product/src/gui/plugin/AlarmWidget_pad/CAlarmDelegate.cpp
Normal file
@ -0,0 +1,307 @@
|
||||
#include <QFile>
|
||||
#include <QPainter>
|
||||
#include <QDomDocument>
|
||||
#include "CAlarmDelegate.h"
|
||||
#include "CAlarmMsgInfo.h"
|
||||
#include "CAlarmItemModel.h"
|
||||
#include "pub_utility_api/FileUtil.h"
|
||||
#include "pub_utility_api/FileStyle.h"
|
||||
#include <QApplication>
|
||||
#include <QMouseEvent>
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include <QProcess>
|
||||
|
||||
CAlarmDelegate::CAlarmDelegate(CAlarmItemModel * model, QObject *parent)
|
||||
: QStyledItemDelegate(parent),
|
||||
m_pModel(model),
|
||||
m_isFlash(false),
|
||||
m_enableTrend(true),
|
||||
m_enableLevel(false),
|
||||
m_enableVideo(true),
|
||||
m_enableWave(true),
|
||||
m_selectIsEmpty(false)
|
||||
{
|
||||
slotLoadConfig();
|
||||
}
|
||||
|
||||
void CAlarmDelegate::setEnableTrend(bool isNeed)
|
||||
{
|
||||
m_enableTrend = isNeed;
|
||||
}
|
||||
|
||||
void CAlarmDelegate::setEnableLevel(bool isNeed)
|
||||
{
|
||||
m_enableLevel = isNeed;
|
||||
}
|
||||
|
||||
void CAlarmDelegate::setEnableVideo(bool isNeed)
|
||||
{
|
||||
m_enableVideo = isNeed;
|
||||
}
|
||||
|
||||
void CAlarmDelegate::setEnableWave(bool isNeed)
|
||||
{
|
||||
m_enableWave = isNeed;
|
||||
}
|
||||
|
||||
void CAlarmDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
if(!index.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
QColor fillColor;
|
||||
QColor penColor;
|
||||
bool select = option.state & QStyle::State_Selected;
|
||||
//< Dock Empty
|
||||
if(E_Alarm_Dock == m_pModel->getAlarmMode() && 0 == m_pModel->getShowAlarmCount())
|
||||
{
|
||||
painter->fillRect(option.rect, m_emptyBackgroundColor);
|
||||
if(CAlarmItemModel::CONTENT == index.column() && parent())
|
||||
{
|
||||
QRect rt = option.rect;
|
||||
QWidget * parentWidget = dynamic_cast<QWidget*>(parent());
|
||||
if(parentWidget)
|
||||
{
|
||||
rt.setLeft(0);
|
||||
rt.setWidth(parentWidget->width());
|
||||
painter->save();
|
||||
painter->setPen(m_emptyTipColor);
|
||||
painter->drawText(rt, Qt::AlignHCenter | Qt::AlignVCenter, m_emptyTip);
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//< Common
|
||||
AlarmMsgPtr info = m_pModel->getAlarmInfo(index);
|
||||
|
||||
|
||||
if(info != Q_NULLPTR)
|
||||
{
|
||||
painter->save();
|
||||
|
||||
if(E_ALS_RETURN == info->logic_state)
|
||||
{
|
||||
if(select)
|
||||
{
|
||||
fillColor = m_select_background_color;
|
||||
if(m_selectIsEmpty)
|
||||
{
|
||||
penColor = m_colorMap.value(info->priorityOrder).resume_text_color;
|
||||
}else
|
||||
{
|
||||
penColor = m_select_text_color;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_isFlash && m_pModel->alternate())
|
||||
{
|
||||
penColor = m_colorMap.value(info->priorityOrder).alternating_color;
|
||||
}
|
||||
else
|
||||
{
|
||||
penColor = m_colorMap.value(info->priorityOrder).resume_text_color;
|
||||
}
|
||||
fillColor = m_colorMap.value(info->priorityOrder).background_color;
|
||||
}
|
||||
}else if(E_ALS_ALARM == info->logic_state)
|
||||
{
|
||||
if(select)
|
||||
{
|
||||
fillColor = m_select_background_color;
|
||||
if(m_selectIsEmpty)
|
||||
{
|
||||
penColor = m_colorMap.value(info->priorityOrder).active_text_color;
|
||||
}else
|
||||
{
|
||||
penColor = m_select_text_color;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_isFlash && m_pModel->alternate())
|
||||
{
|
||||
penColor = m_colorMap.value(info->priorityOrder).alternating_color;
|
||||
}
|
||||
else
|
||||
{
|
||||
penColor = m_colorMap.value(info->priorityOrder).active_text_color;
|
||||
}
|
||||
fillColor = m_colorMap.value(info->priorityOrder).background_color;
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(select)
|
||||
{
|
||||
fillColor = m_select_background_color;
|
||||
}
|
||||
else
|
||||
{
|
||||
fillColor = m_colorMap.value(info->priorityOrder).confirm_color;
|
||||
}
|
||||
penColor = m_colorMap.value(info->priorityOrder).confirm_text_color;
|
||||
}
|
||||
painter->setPen(penColor);
|
||||
painter->fillRect(option.rect, fillColor);
|
||||
|
||||
if(m_enableLevel && ICON_COLUMN == index.column())
|
||||
{
|
||||
painter->save();
|
||||
QStyleOptionButton button;
|
||||
button.state |= QStyle::State_Enabled;
|
||||
button.rect = option.rect;
|
||||
|
||||
button.rect.adjust(12, option.rect.height()/2-10, -(option.rect.width()-40), -(option.rect.height()/2-10));
|
||||
QString file = m_colorMap.value(info->priorityOrder).icon;
|
||||
button.iconSize = QSize(button.rect.width()+2,button.rect.height()+2);
|
||||
button.icon = QIcon(file);
|
||||
button.features = QStyleOptionButton::Flat;
|
||||
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButton,&button,painter);
|
||||
painter->restore();
|
||||
}
|
||||
if(m_enableVideo && BUTTON_COLUMN == index.column() && info->m_needVideoAlm)
|
||||
{
|
||||
painter->save();
|
||||
QStyleOptionButton button;
|
||||
button.state |= QStyle::State_Enabled;
|
||||
button.rect = option.rect;
|
||||
|
||||
button.rect.adjust(option.rect.width() - 40, option.rect.height()/2-10, -12, -(option.rect.height()/2-10));
|
||||
button.iconSize = QSize(button.rect.width()+2,button.rect.height()+2);
|
||||
button.icon = QIcon(m_strVideoPath);
|
||||
button.features = QStyleOptionButton::Flat;
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButton,&button,painter);
|
||||
painter->restore();
|
||||
}
|
||||
if( m_enableTrend && BUTTON_COLUMN == index.column() && (info->m_tagname_type == E_TAGNAME_ANA || info->m_tagname_type == E_TAGNAME_ACC))
|
||||
{
|
||||
painter->save();
|
||||
QStyleOptionButton button;
|
||||
button.state |= QStyle::State_Enabled;
|
||||
button.rect = option.rect;
|
||||
|
||||
button.rect.adjust(option.rect.width() - 40 -40, option.rect.height()/2-10, -12-40, -(option.rect.height()/2-10));
|
||||
button.iconSize = QSize(button.rect.width()+2,button.rect.height()+2);
|
||||
button.icon = QIcon(m_strTrendPath);
|
||||
button.features = QStyleOptionButton::Flat;
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButton,&button,painter);
|
||||
painter->restore();
|
||||
}
|
||||
if(m_enableWave && BUTTON_COLUMN == index.column() && !info->wave_file.isEmpty())
|
||||
{
|
||||
painter->save();
|
||||
QStyleOptionButton button;
|
||||
button.state |= QStyle::State_Enabled;
|
||||
button.rect = option.rect;
|
||||
|
||||
button.rect.adjust(option.rect.width() - 40-40-40, option.rect.height()/2-10, -12-40-40, -(option.rect.height()/2-10));
|
||||
button.iconSize = QSize(button.rect.width()+2,button.rect.height()+2);
|
||||
button.icon = QIcon(m_strWavePath);
|
||||
button.features = QStyleOptionButton::Flat;
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButton,&button,painter);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
painter->drawText(option.rect, m_pModel->data(index, Qt::TextAlignmentRole).toInt(), m_pModel->data(index).toString());
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
|
||||
bool CAlarmDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
|
||||
{
|
||||
if(!index.isValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(index.column() != BUTTON_COLUMN)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
AlarmMsgPtr info = m_pModel->getAlarmInfo(index);
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
if(info && m_enableVideo && info->m_needVideoAlm)
|
||||
{
|
||||
if(mouseEvent != NULL && mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
QStyleOptionButton button;
|
||||
button.rect = option.rect;
|
||||
button.rect.adjust(option.rect.width() - 42, option.rect.height()/2-10, -10, -(option.rect.height()/2-10));
|
||||
QRect rect = button.rect;
|
||||
if(rect.contains(mouseEvent->pos()))
|
||||
{
|
||||
QString pointTag = info->key_id_tag;
|
||||
pointTag.remove(pointTag.length()-6,6);
|
||||
emit openVideo(info->domain_id,info->app_id,pointTag,info->time_stamp-VIDEO_TIME,info->time_stamp+VIDEO_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(info && m_enableTrend && (info->m_tagname_type == E_TAGNAME_ACC || info->m_tagname_type == E_TAGNAME_ANA ))
|
||||
{
|
||||
if(mouseEvent != NULL && mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
QStyleOptionButton button;
|
||||
button.rect = option.rect;
|
||||
button.rect.adjust(option.rect.width() - 82, option.rect.height()/2-10, -50, -(option.rect.height()/2-10));
|
||||
QRect rect = button.rect;
|
||||
if(rect.contains(mouseEvent->pos()))
|
||||
{
|
||||
QStringList trendList;
|
||||
trendList.append(info->key_id_tag);
|
||||
emit openTrend(info->time_stamp,trendList);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(info && m_enableWave && !info->wave_file.isEmpty())
|
||||
{
|
||||
if(mouseEvent != NULL && mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
QStyleOptionButton button;
|
||||
button.rect = option.rect;
|
||||
button.rect.adjust(option.rect.width() - 122, option.rect.height()/2-10, -90, -(option.rect.height()/2-10));
|
||||
QRect rect = button.rect;
|
||||
if(rect.contains(mouseEvent->pos()))
|
||||
{
|
||||
QString wave = info->wave_file;
|
||||
wave = QString("%1%2%3").arg("\"").arg(wave).arg("\"");
|
||||
LOGINFO("录波文件为:%s",wave.toStdString().c_str());
|
||||
|
||||
const std::string strProc = std::move(iot_public::CFileUtil::getPathOfBinFile(
|
||||
std::string("WaveAnalyze") + iot_public::CFileUtil::getProcSuffix()));
|
||||
if(strProc.empty())
|
||||
LOGERROR("未找到可执行文件WaveAnalyze");
|
||||
else
|
||||
QProcess::startDetached(QString("%1 %2").arg(strProc.c_str()).arg(wave));
|
||||
}
|
||||
}
|
||||
}
|
||||
return QStyledItemDelegate::editorEvent(event, model, option, index);
|
||||
}
|
||||
|
||||
void CAlarmDelegate::slotLoadConfig()
|
||||
{
|
||||
CAlarmSetMng::instance()->getColorMap(m_colorMap);
|
||||
CAlarmSetMng::instance()->getSelectInfo(m_selectIsEmpty,m_select_background_color,m_select_text_color);
|
||||
CAlarmSetMng::instance()->getEmptyInfo(m_emptyBackgroundColor,m_emptyTipColor,m_emptyTip);
|
||||
//CAlarmColorMng::instance()->getActAndFunc(m_act,m_func);
|
||||
if(E_Alarm_Pop == m_pModel->getAlarmMode())
|
||||
{
|
||||
m_isFlash = false;
|
||||
}
|
||||
else if(E_Alarm_Dock == m_pModel->getAlarmMode())
|
||||
{
|
||||
m_isFlash = true;
|
||||
}
|
||||
else if(E_Alarm_Window == m_pModel->getAlarmMode())
|
||||
{
|
||||
m_isFlash = false;
|
||||
}
|
||||
|
||||
std::string style = iot_public::CFileStyle::getCurStyle();
|
||||
m_strTrendPath = iot_public::CFileUtil::getPathOfResFile("gui/icon/alarm/trend_"+style+".png").c_str();
|
||||
m_strVideoPath = iot_public::CFileUtil::getPathOfResFile("gui/icon/alarm/video_"+style+".png").c_str();
|
||||
m_strWavePath = iot_public::CFileUtil::getPathOfResFile("gui/icon/alarm/wave_"+style+".png").c_str();
|
||||
}
|
||||
53
product/src/gui/plugin/AlarmWidget_pad/CAlarmDelegate.h
Normal file
53
product/src/gui/plugin/AlarmWidget_pad/CAlarmDelegate.h
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef CALARMDELEGATE_H
|
||||
#define CALARMDELEGATE_H
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
#include "CAlarmSetMng.h"
|
||||
|
||||
class CAlarmItemModel;
|
||||
|
||||
class CAlarmDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CAlarmDelegate(CAlarmItemModel *model, QObject *parent = 0);
|
||||
void setEnableTrend(bool isNeed);
|
||||
void setEnableLevel(bool isNeed);
|
||||
void setEnableVideo(bool isNeed);
|
||||
void setEnableWave(bool isNeed);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
bool editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||
const QStyleOptionViewItem &option, const QModelIndex &index) Q_DECL_OVERRIDE;
|
||||
|
||||
signals:
|
||||
void openVideo(int domainId,int appId,QString tag,quint64 startTime,quint64 endTime);
|
||||
void openTrend(quint64 time_stamp,QStringList tagList);
|
||||
|
||||
public slots:
|
||||
void slotLoadConfig();
|
||||
|
||||
private:
|
||||
CAlarmItemModel * m_pModel;
|
||||
bool m_isFlash;
|
||||
|
||||
bool m_enableTrend;
|
||||
bool m_enableLevel;
|
||||
bool m_enableVideo;
|
||||
bool m_enableWave;
|
||||
|
||||
QMap<int,CAlarmColorInfo> m_colorMap;
|
||||
QColor m_select_background_color,m_select_text_color; //选中告警背景色和文字颜色
|
||||
bool m_selectIsEmpty;
|
||||
|
||||
QColor m_emptyBackgroundColor,m_emptyTipColor;
|
||||
QString m_emptyTip;
|
||||
int m_act;
|
||||
int m_func;
|
||||
|
||||
QString m_strWavePath;
|
||||
QString m_strVideoPath;
|
||||
QString m_strTrendPath;
|
||||
};
|
||||
|
||||
#endif
|
||||
159
product/src/gui/plugin/AlarmWidget_pad/CAlarmDeviceTreeItem.cpp
Normal file
159
product/src/gui/plugin/AlarmWidget_pad/CAlarmDeviceTreeItem.cpp
Normal file
@ -0,0 +1,159 @@
|
||||
#include <QStringList>
|
||||
#include "CAlarmDeviceTreeItem.h"
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include "Common.h"
|
||||
|
||||
const int TypeRole = Qt::UserRole + 1;
|
||||
const int TagRole = Qt::UserRole + 2;
|
||||
const int DomainRole = Qt::UserRole + 3;
|
||||
const int LocationRole = Qt::UserRole + 4;
|
||||
const int SubsystemRole = Qt::UserRole + 5;
|
||||
const int RegionRole = Qt::UserRole + 6;
|
||||
|
||||
CAlarmDeviceTreeItem::CAlarmDeviceTreeItem(const QString &data, CAlarmDeviceTreeItem *parent)
|
||||
: m_tag(QString()),
|
||||
m_nDomain(CN_InvalidDomainId),
|
||||
m_nLocation(CN_InvalidLocationId),
|
||||
m_nSubsystem(CN_InvalidSubsystemId),
|
||||
m_nType(0),
|
||||
m_nRegion(0),
|
||||
m_parentItem(parent)
|
||||
{
|
||||
if(m_parentItem)
|
||||
{
|
||||
m_parentItem->m_childItems.append(this);
|
||||
}
|
||||
|
||||
m_data = data;
|
||||
m_checkState = Qt::Checked;
|
||||
}
|
||||
|
||||
CAlarmDeviceTreeItem::~CAlarmDeviceTreeItem()
|
||||
{
|
||||
qDeleteAll(m_childItems);
|
||||
m_childItems.clear();
|
||||
}
|
||||
|
||||
CAlarmDeviceTreeItem *CAlarmDeviceTreeItem::child(int row)
|
||||
{
|
||||
return m_childItems.value(row);
|
||||
}
|
||||
|
||||
CAlarmDeviceTreeItem *CAlarmDeviceTreeItem::parentItem()
|
||||
{
|
||||
return m_parentItem;
|
||||
}
|
||||
|
||||
int CAlarmDeviceTreeItem::row() const
|
||||
{
|
||||
if (m_parentItem)
|
||||
{
|
||||
return m_parentItem->m_childItems.indexOf(const_cast<CAlarmDeviceTreeItem*>(this));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAlarmDeviceTreeItem::childCount() const
|
||||
{
|
||||
return m_childItems.count();
|
||||
}
|
||||
|
||||
int CAlarmDeviceTreeItem::columnCount() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
QVariant CAlarmDeviceTreeItem::data(Qt::ItemDataRole role) const
|
||||
{
|
||||
if(Qt::DisplayRole == role)
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
else if(Qt::CheckStateRole == role)
|
||||
{
|
||||
return m_checkState;
|
||||
}
|
||||
else if(Qt::ItemDataRole(TypeRole) == role)
|
||||
{
|
||||
return m_nType;
|
||||
}
|
||||
else if(Qt::ItemDataRole(TagRole) == role)
|
||||
{
|
||||
return m_tag;
|
||||
}
|
||||
else if(Qt::ItemDataRole(DomainRole) == role)
|
||||
{
|
||||
return m_nDomain;
|
||||
}
|
||||
else if(Qt::ItemDataRole(LocationRole) == role)
|
||||
{
|
||||
return m_nLocation;
|
||||
}
|
||||
else if(Qt::ItemDataRole(SubsystemRole) == role)
|
||||
{
|
||||
return m_nSubsystem;
|
||||
}
|
||||
else if(Qt::ItemDataRole(RegionRole) == role)
|
||||
{
|
||||
return m_nRegion;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool CAlarmDeviceTreeItem::setData(const QVariant &value, Qt::ItemDataRole role)
|
||||
{
|
||||
if(Qt::DisplayRole == role)
|
||||
{
|
||||
m_data = value.toString();
|
||||
return true;
|
||||
}
|
||||
else if(Qt::CheckStateRole == role)
|
||||
{
|
||||
m_checkState = (Qt::CheckState)value.toInt();
|
||||
return true;
|
||||
}
|
||||
else if(TypeRole == role)
|
||||
{
|
||||
m_nType = value.toInt();
|
||||
return true;
|
||||
}
|
||||
else if(TagRole == role)
|
||||
{
|
||||
m_tag = value.toString();
|
||||
return true;
|
||||
}
|
||||
else if(DomainRole == role)
|
||||
{
|
||||
m_nDomain = value.toInt();
|
||||
return true;
|
||||
}
|
||||
else if(LocationRole == role)
|
||||
{
|
||||
m_nLocation = value.toInt();
|
||||
return true;
|
||||
}
|
||||
else if(SubsystemRole == role)
|
||||
{
|
||||
m_nSubsystem = value.toInt();
|
||||
return true;
|
||||
}
|
||||
else if(RegionRole == role)
|
||||
{
|
||||
m_nRegion = value.toInt();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CAlarmDeviceTreeItem::removeChildren(int position, int count, int columns)
|
||||
{
|
||||
Q_UNUSED(columns)
|
||||
if (position < 0 || position + count > m_childItems.size())
|
||||
return false;
|
||||
|
||||
for (int row = 0; row < count; ++row)
|
||||
delete m_childItems.takeAt(position);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** BSD License Usage
|
||||
** Alternatively, you may use this file under the terms of the BSD license
|
||||
** as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||
** contributors may be used to endorse or promote products derived
|
||||
** from this software without specific prior written permission.
|
||||
**
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CALARMDEVICETREEITEM_H
|
||||
#define CALARMDEVICETREEITEM_H
|
||||
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
|
||||
extern const int TypeRole;
|
||||
extern const int TagRole;
|
||||
extern const int DomainRole;
|
||||
extern const int LocationRole;
|
||||
extern const int SubsystemRole;
|
||||
extern const int RegionRole;
|
||||
|
||||
class CAlarmDeviceTreeItem
|
||||
{
|
||||
public:
|
||||
explicit CAlarmDeviceTreeItem(const QString &data = QString(), CAlarmDeviceTreeItem *parentItem = Q_NULLPTR);
|
||||
~CAlarmDeviceTreeItem();
|
||||
|
||||
CAlarmDeviceTreeItem *child(int row);
|
||||
CAlarmDeviceTreeItem *parentItem();
|
||||
|
||||
int row() const;
|
||||
|
||||
int childCount() const;
|
||||
int columnCount() const;
|
||||
|
||||
QVariant data(Qt::ItemDataRole role = Qt::DisplayRole) const;
|
||||
bool setData(const QVariant &value, Qt::ItemDataRole role);
|
||||
bool removeChildren(int position, int count, int columns);
|
||||
private:
|
||||
QString m_tag;
|
||||
int m_nDomain;
|
||||
int m_nLocation;
|
||||
int m_nSubsystem;
|
||||
int m_nRegion;
|
||||
int m_nType;
|
||||
QString m_data;
|
||||
Qt::CheckState m_checkState;
|
||||
|
||||
QList<CAlarmDeviceTreeItem*> m_childItems;
|
||||
CAlarmDeviceTreeItem *m_parentItem;
|
||||
};
|
||||
|
||||
#endif // CALARMDEVICETREEITEM_H
|
||||
312
product/src/gui/plugin/AlarmWidget_pad/CAlarmDeviceTreeModel.cpp
Normal file
312
product/src/gui/plugin/AlarmWidget_pad/CAlarmDeviceTreeModel.cpp
Normal file
@ -0,0 +1,312 @@
|
||||
#include "CAlarmDeviceTreeItem.h"
|
||||
#include "CAlarmDeviceTreeModel.h"
|
||||
#include "CAlarmMsgManage.h"
|
||||
#include "CAlarmBaseData.h"
|
||||
#include <QStringList>
|
||||
#include "pub_logger_api/logger.h"
|
||||
CAlarmDeviceTreeModel::CAlarmDeviceTreeModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
rootItem = new CAlarmDeviceTreeItem();
|
||||
m_sysInfoItem = NULL;
|
||||
}
|
||||
|
||||
CAlarmDeviceTreeModel::~CAlarmDeviceTreeModel()
|
||||
{
|
||||
m_devTagIndex.clear();
|
||||
m_devNameIndex.clear();
|
||||
delete rootItem;
|
||||
}
|
||||
|
||||
void CAlarmDeviceTreeModel::setupModelData(const QMap<int, QVector<SDevGroupInfo> > locationInfos, const QList<int> &locationList)
|
||||
{
|
||||
for(int nLocIndex(0); nLocIndex<locationList.length(); nLocIndex++)
|
||||
{
|
||||
const QString locDesc = CAlarmBaseData::instance()->getPermLocationDesc(locationList[nLocIndex]);
|
||||
CAlarmDeviceTreeItem * location = new CAlarmDeviceTreeItem(locDesc, rootItem);
|
||||
location->setData(TYPE_LOCATION,Qt::ItemDataRole(TypeRole));
|
||||
const QVector<SDevGroupInfo> vec = locationInfos.value(locationList[nLocIndex]);
|
||||
for(int nDevIndex(0); nDevIndex < vec.size(); ++nDevIndex)
|
||||
{
|
||||
CAlarmDeviceTreeItem * device = new CAlarmDeviceTreeItem(vec.at(nDevIndex).description, location);
|
||||
device->setData(vec.at(nDevIndex).tag_name, Qt::ItemDataRole(TagRole));
|
||||
device->setData(TYPE_DEVGROUP, Qt::ItemDataRole(TypeRole));
|
||||
device->setData(vec.at(nDevIndex).domain, Qt::ItemDataRole(DomainRole));
|
||||
device->setData(vec.at(nDevIndex).location, Qt::ItemDataRole(LocationRole));
|
||||
device->setData(vec.at(nDevIndex).sub_system, Qt::ItemDataRole(SubsystemRole));
|
||||
device->setData(vec.at(nDevIndex).region, Qt::ItemDataRole(RegionRole));
|
||||
QModelIndex modelIndex = createIndex(nDevIndex, 0, device);
|
||||
m_devTagIndex.insert(vec.at(nDevIndex).tag_name, modelIndex);
|
||||
m_devNameIndex.insert(locDesc + "." + vec.at(nDevIndex).description, modelIndex);
|
||||
}
|
||||
}
|
||||
|
||||
CAlarmDeviceTreeItem * location = new CAlarmDeviceTreeItem(QString(tr("系统信息")), rootItem);
|
||||
location->setData(TYPE_SYSINFO, Qt::ItemDataRole(TypeRole));
|
||||
m_sysInfoItem = location;
|
||||
}
|
||||
|
||||
const HashIndex &CAlarmDeviceTreeModel::indexTagList() const
|
||||
{
|
||||
return m_devTagIndex;
|
||||
}
|
||||
|
||||
const HashIndex &CAlarmDeviceTreeModel::indexNameList() const
|
||||
{
|
||||
return m_devNameIndex;
|
||||
}
|
||||
|
||||
QModelIndex CAlarmDeviceTreeModel::indexOfDeviceTag(const QString &tag)
|
||||
{
|
||||
return m_devTagIndex.value(tag, QModelIndex());
|
||||
}
|
||||
|
||||
QModelIndex CAlarmDeviceTreeModel::indexOfDeviceName(const QString &name)
|
||||
{
|
||||
return m_devNameIndex.value(name, QModelIndex());
|
||||
}
|
||||
|
||||
QVariant CAlarmDeviceTreeModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
Q_UNUSED(section)
|
||||
Q_UNUSED(orientation)
|
||||
Q_UNUSED(role)
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QModelIndex CAlarmDeviceTreeModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (!hasIndex(row, column, parent))
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
CAlarmDeviceTreeItem *parentItem;
|
||||
|
||||
if (!parent.isValid())
|
||||
{
|
||||
parentItem = rootItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
parentItem = static_cast<CAlarmDeviceTreeItem*>(parent.internalPointer());
|
||||
}
|
||||
|
||||
CAlarmDeviceTreeItem *childItem = parentItem->child(row);
|
||||
if (childItem)
|
||||
{
|
||||
return createIndex(row, column, childItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex CAlarmDeviceTreeModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
CAlarmDeviceTreeItem *childItem = static_cast<CAlarmDeviceTreeItem*>(index.internalPointer());
|
||||
|
||||
CAlarmDeviceTreeItem *parentItem = childItem->parentItem();
|
||||
if (parentItem == rootItem)
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
return createIndex(parentItem->row(), 0, parentItem);
|
||||
}
|
||||
|
||||
int CAlarmDeviceTreeModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.column() > 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
CAlarmDeviceTreeItem *parentItem;
|
||||
if (!parent.isValid())
|
||||
{
|
||||
parentItem = rootItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
parentItem = static_cast<CAlarmDeviceTreeItem*>(parent.internalPointer());
|
||||
}
|
||||
|
||||
return parentItem->childCount();
|
||||
}
|
||||
|
||||
int CAlarmDeviceTreeModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
{
|
||||
return static_cast<CAlarmDeviceTreeItem*>(parent.internalPointer())->columnCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
return rootItem->columnCount();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QVariant CAlarmDeviceTreeModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.column())
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
CAlarmDeviceTreeItem *item = static_cast<CAlarmDeviceTreeItem*>(index.internalPointer());
|
||||
int itemType = item->data(Qt::ItemDataRole(TypeRole)).toInt();
|
||||
|
||||
if (Qt::DisplayRole == role)
|
||||
{
|
||||
const QString &deviceGroup = item->data(Qt::ItemDataRole(TagRole)).toString();
|
||||
if (itemType == enTreeNodeType::TYPE_LOCATION)
|
||||
{
|
||||
return item->data(Qt::DisplayRole).toString();
|
||||
}
|
||||
else if (itemType == enTreeNodeType::TYPE_SYSINFO)
|
||||
{
|
||||
return QString(tr("系统信息")) + QString(" [%1]").arg(m_alarmDeviceGroupStatistical.value(deviceGroup, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (deviceGroup.isEmpty())
|
||||
{
|
||||
return item->data(Qt::DisplayRole).toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return item->data(Qt::DisplayRole).toString() + QString(" [%1]").arg(m_alarmDeviceGroupStatistical.value(deviceGroup, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(Qt::CheckStateRole == role && itemType != enTreeNodeType::TYPE_LOCATION)
|
||||
{
|
||||
return item->data(Qt::CheckStateRole);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool CAlarmDeviceTreeModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (!index.isValid() || index.column())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(Qt::CheckStateRole == role)
|
||||
{
|
||||
emit itemCheckStateChanged(static_cast<CAlarmDeviceTreeItem*>(index.internalPointer())->data(Qt::ItemDataRole(TagRole)).toString(), value.toBool());
|
||||
}
|
||||
return static_cast<CAlarmDeviceTreeItem*>(index.internalPointer())->setData(value, (Qt::ItemDataRole)role);
|
||||
}
|
||||
|
||||
Qt::ItemFlags CAlarmDeviceTreeModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
{
|
||||
return Qt::NoItemFlags;
|
||||
}
|
||||
if(!index.column())
|
||||
{
|
||||
return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable;
|
||||
}
|
||||
return QAbstractItemModel::flags(index);
|
||||
}
|
||||
|
||||
void CAlarmDeviceTreeModel::setDeviceCheckState(const QModelIndex &index, const Qt::CheckState &state)
|
||||
{
|
||||
if(!index.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
CAlarmDeviceTreeItem * pItem = static_cast<CAlarmDeviceTreeItem*>(index.internalPointer());
|
||||
if(pItem)
|
||||
{
|
||||
int nChildCount = pItem->childCount();
|
||||
for( int nIndex(0); nIndex < nChildCount; nIndex++)
|
||||
{
|
||||
pItem->child(nIndex)->setData(state, Qt::CheckStateRole);
|
||||
emit itemCheckStateChanged(pItem->child(nIndex)->data(Qt::ItemDataRole(TagRole)).toString(), state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmDeviceTreeModel::setAllDeviceCheckState(const Qt::CheckState &state)
|
||||
{
|
||||
HashIndex::const_iterator iter = m_devTagIndex.constBegin();
|
||||
while (iter != m_devTagIndex.constEnd())
|
||||
{
|
||||
CAlarmDeviceTreeItem * pItem = static_cast<CAlarmDeviceTreeItem*>(iter.value().internalPointer());
|
||||
if(pItem)
|
||||
{
|
||||
pItem->setData(state, Qt::CheckStateRole);
|
||||
emit itemCheckStateChanged(pItem->data(Qt::ItemDataRole(TagRole)).toString(), state);
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
|
||||
if(m_sysInfoItem)
|
||||
{
|
||||
m_sysInfoItem->setData(state, Qt::CheckStateRole);
|
||||
emit itemCheckStateChanged(m_sysInfoItem->data(Qt::ItemDataRole(TagRole)).toString(), state);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmDeviceTreeModel::removeData()
|
||||
{
|
||||
m_alarmDeviceGroupStatistical.clear();
|
||||
QModelIndex modelindex = QModelIndex();
|
||||
if(rootItem->childCount()>0)
|
||||
{
|
||||
beginRemoveRows(modelindex, 0, rootItem->childCount()-1);
|
||||
rootItem->removeChildren(0, rootItem->childCount(), rootItem->columnCount());
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
|
||||
QHash<QString, int> CAlarmDeviceTreeModel::getDeviceStatisticalInfo()
|
||||
{
|
||||
return m_alarmDeviceGroupStatistical;
|
||||
}
|
||||
|
||||
void CAlarmDeviceTreeModel::slotDevTreeUpdate()
|
||||
{
|
||||
m_alarmDeviceGroupStatistical.clear();
|
||||
m_alarmDeviceGroupStatistical = CAlarmMsgManage::instance()->getDeviceStatisticalInfo();
|
||||
}
|
||||
|
||||
void CAlarmDeviceTreeModel::slotTreeCheckBoxState(const QModelIndex &index)
|
||||
{
|
||||
if(!index.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
CAlarmDeviceTreeItem *pItem = static_cast<CAlarmDeviceTreeItem*>(index.internalPointer());
|
||||
if(pItem)
|
||||
{
|
||||
int itemType = pItem->data(Qt::ItemDataRole(TypeRole)).toInt();
|
||||
if (itemType == enTreeNodeType::TYPE_LOCATION)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(data(index , Qt::CheckStateRole) == Qt::Unchecked)
|
||||
{
|
||||
pItem->setData(Qt::Checked , Qt::CheckStateRole);
|
||||
emit itemCheckStateChanged(pItem->data(Qt::ItemDataRole(TagRole)).toString(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
pItem->setData(Qt::Unchecked , Qt::CheckStateRole);
|
||||
emit itemCheckStateChanged(pItem->data(Qt::ItemDataRole(TagRole)).toString(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
128
product/src/gui/plugin/AlarmWidget_pad/CAlarmDeviceTreeModel.h
Normal file
128
product/src/gui/plugin/AlarmWidget_pad/CAlarmDeviceTreeModel.h
Normal file
@ -0,0 +1,128 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** BSD License Usage
|
||||
** Alternatively, you may use this file under the terms of the BSD license
|
||||
** as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||
** contributors may be used to endorse or promote products derived
|
||||
** from this software without specific prior written permission.
|
||||
**
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CALARMDEVICETREEMODEL_H
|
||||
#define CALARMDEVICETREEMODEL_H
|
||||
|
||||
#include "CAlarmCommon.h"
|
||||
#include <QAbstractItemModel>
|
||||
#include <QModelIndex>
|
||||
#include <QVariant>
|
||||
#include <QHash>
|
||||
|
||||
enum enTreeNodeType{
|
||||
TYPE_LOCATION = 0,
|
||||
TYPE_DEVGROUP,
|
||||
TYPE_SYSINFO
|
||||
};
|
||||
typedef QHash< QString, QModelIndex > HashIndex; //< Device<tag-index>
|
||||
|
||||
class CAlarmDeviceTreeItem;
|
||||
|
||||
class CAlarmDeviceTreeModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CAlarmDeviceTreeModel(QObject *parent = 0);
|
||||
~CAlarmDeviceTreeModel();
|
||||
|
||||
//< @param locationInfos [ locationDesc[ devTag, devDesc ] ]
|
||||
void setupModelData(const QMap<int, QVector<SDevGroupInfo> > locationInfos, const QList<int> &locationList);
|
||||
|
||||
const HashIndex &indexTagList() const;
|
||||
|
||||
const HashIndex &indexNameList() const;
|
||||
|
||||
QModelIndex indexOfDeviceTag(const QString &tag);
|
||||
|
||||
QModelIndex indexOfDeviceName(const QString &name);
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation,int role = Qt::DisplayRole) const override;
|
||||
|
||||
QModelIndex index(int row, int column,const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
QModelIndex parent(const QModelIndex &index) const override;
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
void setDeviceCheckState(const QModelIndex &index, const Qt::CheckState &state);
|
||||
|
||||
void setAllDeviceCheckState(const Qt::CheckState &state);
|
||||
|
||||
void removeData();
|
||||
|
||||
QHash<QString, int> getDeviceStatisticalInfo();
|
||||
|
||||
signals:
|
||||
void itemCheckStateChanged(const QString &device, const bool &checked);
|
||||
|
||||
void inhibitDevGroupAlm(const QString &devGroup, int nDomain, int nLocation, int nSubsystem, int nRegion);
|
||||
|
||||
public slots:
|
||||
void slotDevTreeUpdate();
|
||||
|
||||
void slotTreeCheckBoxState(const QModelIndex & index);
|
||||
private:
|
||||
CAlarmDeviceTreeItem *rootItem;
|
||||
HashIndex m_devTagIndex;
|
||||
HashIndex m_devNameIndex;
|
||||
HashIndex m_devGroupIndex;
|
||||
CAlarmDeviceTreeItem* m_sysInfoItem;
|
||||
QHash<QString, int> m_alarmDeviceGroupStatistical; //<设备组告警数量统计
|
||||
};
|
||||
|
||||
#endif // CALARMDEVICETREEMODEL_H
|
||||
@ -0,0 +1,57 @@
|
||||
#include "CAlarmDeviceTreeView.h"
|
||||
#include "CAlarmDeviceTreeModel.h"
|
||||
#include "CAlarmDeviceTreeItem.h"
|
||||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
|
||||
CAlarmDeviceTreeView::CAlarmDeviceTreeView(QWidget *parent)
|
||||
: QTreeView(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CAlarmDeviceTreeView::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
CAlarmDeviceTreeModel * pModel = dynamic_cast<CAlarmDeviceTreeModel *>(model());
|
||||
if(Q_NULLPTR != pModel)
|
||||
{
|
||||
QMenu menu(this);
|
||||
CAlarmDeviceTreeItem * pItem = static_cast<CAlarmDeviceTreeItem*>(indexAt(event->pos()).internalPointer());
|
||||
if (pItem)
|
||||
{
|
||||
if(pItem->data(Qt::ItemDataRole(TypeRole)).toInt() == TYPE_DEVGROUP)
|
||||
{
|
||||
menu.addAction(tr("禁止告警"), [=](){ emit pModel->inhibitDevGroupAlm(pItem->data(Qt::ItemDataRole(TagRole)).toString(),
|
||||
pItem->data(Qt::ItemDataRole(DomainRole)).toInt(),
|
||||
pItem->data(Qt::ItemDataRole(LocationRole)).toInt(),
|
||||
pItem->data(Qt::ItemDataRole(SubsystemRole)).toInt(),
|
||||
pItem->data(Qt::ItemDataRole(RegionRole)).toInt()); });
|
||||
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//void CAlarmDeviceTreeView::contextMenuEvent(QContextMenuEvent *event)
|
||||
//{
|
||||
// CAlarmDeviceTreeModel * pModel = dynamic_cast<CAlarmDeviceTreeModel *>(model());
|
||||
// if(Q_NULLPTR != pModel)
|
||||
// {
|
||||
// QMenu menu;
|
||||
// CAlarmDeviceTreeItem * pItem = static_cast<CAlarmDeviceTreeItem*>(indexAt(event->pos()).internalPointer());
|
||||
// if (Q_NULLPTR == pItem)
|
||||
// {
|
||||
// menu.addAction(tr("全选"), [=](){ pModel->setAllDeviceCheckState(Qt::Checked); });
|
||||
// menu.addAction(tr("清空"), [=](){ pModel->setAllDeviceCheckState(Qt::Unchecked); });
|
||||
// }
|
||||
// else if (Q_NULLPTR != pItem && pItem->childCount() > 0)
|
||||
// {
|
||||
// menu.addAction(tr("选择"), [=](){ pModel->setDeviceCheckState(indexAt(event->pos()), Qt::Checked); });
|
||||
// menu.addAction(tr("清除"), [=](){ pModel->setDeviceCheckState(indexAt(event->pos()), Qt::Unchecked); });
|
||||
// }
|
||||
// menu.exec(event->globalPos());
|
||||
// }
|
||||
// return;
|
||||
//}
|
||||
@ -0,0 +1,16 @@
|
||||
#ifndef CALARMDEVICETREEVIEW_H
|
||||
#define CALARMDEVICETREEVIEW_H
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
class CAlarmDeviceTreeView : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CAlarmDeviceTreeView(QWidget *parent = Q_NULLPTR);
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
};
|
||||
|
||||
#endif // CALARMDEVICETREEVIEW_H
|
||||
868
product/src/gui/plugin/AlarmWidget_pad/CAlarmFilterDialog.cpp
Normal file
868
product/src/gui/plugin/AlarmWidget_pad/CAlarmFilterDialog.cpp
Normal file
@ -0,0 +1,868 @@
|
||||
#include "CAlarmFilterDialog.h"
|
||||
#include "ui_CAlarmFilterDialog.h"
|
||||
#include "public/pub_sysinfo_api/SysInfoApi.h"
|
||||
#include "pub_utility_api/FileStyle.h"
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include "CAlarmBaseData.h"
|
||||
|
||||
int CAlarmFilterDialog::windowMinWidth()
|
||||
{
|
||||
return m_nMinWidth;
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setWindowMinWidth(int nWidth)
|
||||
{
|
||||
m_nMinWidth = nWidth;
|
||||
setMinimumWidth(m_nMinWidth);
|
||||
}
|
||||
|
||||
int CAlarmFilterDialog::windowMinHeigth()
|
||||
{
|
||||
return m_nMinHeight;
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setWindowMinHeigth(int nHeight)
|
||||
{
|
||||
m_nMinHeight = nHeight;
|
||||
setMinimumHeight(m_nMinHeight);
|
||||
}
|
||||
|
||||
CAlarmFilterDialog::CAlarmFilterDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CAlarmFilterDialog),
|
||||
m_rtdbAccess(Q_NULLPTR),
|
||||
m_nMinWidth(0),
|
||||
m_nMinHeight(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setObjectName("alarm_dialog");
|
||||
QString qss = QString();
|
||||
std::string strFullPath = iot_public::CFileStyle::getPathOfStyleFile("public.qss") ;
|
||||
QFile qssfile1(QString::fromStdString(strFullPath));
|
||||
qssfile1.open(QFile::ReadOnly);
|
||||
if (qssfile1.isOpen())
|
||||
{
|
||||
qss += QLatin1String(qssfile1.readAll());
|
||||
qssfile1.close();
|
||||
}
|
||||
strFullPath = iot_public::CFileStyle::getPathOfStyleFile("alarm.qss") ;
|
||||
QFile qssfile2(QString::fromStdString(strFullPath));
|
||||
qssfile2.open(QFile::ReadOnly);
|
||||
if (qssfile2.isOpen())
|
||||
{
|
||||
qss += QLatin1String(qssfile2.readAll());
|
||||
qssfile2.close();
|
||||
}
|
||||
if(!qss.isEmpty())
|
||||
{
|
||||
setStyleSheet(qss);
|
||||
}
|
||||
|
||||
/*隐藏多余
|
||||
*2023年1月5日08:43:47 修改
|
||||
*/
|
||||
ui->levelFilter->hide();
|
||||
ui->locationFilter->hide();
|
||||
ui->regionFilter->hide();
|
||||
ui->returnFilterEnable->hide();
|
||||
ui->stateFilterEnable->hide();
|
||||
ui->alarmStatusFilter->hide();
|
||||
ui->keywordFilterEnable->hide();
|
||||
|
||||
|
||||
ui->startTime->setCalendarPopup(true);
|
||||
ui->endTime->setCalendarPopup(true);
|
||||
|
||||
ui->subSystem->setView(new QListView());
|
||||
ui->deviceType->setView(new QListView());
|
||||
m_priorityMap = CAlarmBaseData::instance()->getPermPriorityMap();
|
||||
m_locationMap = CAlarmBaseData::instance()->getPermLocationMap();
|
||||
m_regionMap = CAlarmBaseData::instance()->getPermRegionMap();
|
||||
m_alarmStatusMap = CAlarmBaseData::instance()->getAlarmShowStatusMap();
|
||||
m_areaLocMap = CAlarmBaseData::instance()->getAreaLocMap();
|
||||
m_areaInfoMap= CAlarmBaseData::instance()->getAreaInfoMap();
|
||||
}
|
||||
|
||||
CAlarmFilterDialog::~CAlarmFilterDialog()
|
||||
{
|
||||
if(m_rtdbAccess)
|
||||
{
|
||||
delete m_rtdbAccess;
|
||||
}
|
||||
m_rtdbAccess = Q_NULLPTR;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::initialize()
|
||||
{
|
||||
// if(nullptr == ui->gridLayout_5)
|
||||
// return;
|
||||
// int numcolumn = ui->gridLayout_5->columnCount();
|
||||
// int numrow = ui->gridLayout_5->rowCount();
|
||||
// for(int i=0;i<numcolumn;++i)
|
||||
// {
|
||||
// for(int j=0;j<numrow;++j)
|
||||
// {
|
||||
// QLayoutItem *item = ui->gridLayout_5->itemAtPosition(i,j);
|
||||
// if(item)
|
||||
// item->widget()->setEnabled(false);
|
||||
// }
|
||||
// }
|
||||
|
||||
m_rtdbAccess = new iot_dbms::CRdbAccess();
|
||||
|
||||
ui->level->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
//ui->location->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
ui->region->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
ui->status->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
|
||||
foreach (QString value, m_priorityMap)
|
||||
{
|
||||
ui->level->addItem(value);
|
||||
}
|
||||
ui->area->clear();
|
||||
ui->area->setColumnCount(1);
|
||||
bool isArea = false;
|
||||
QMap<int,QVector<int> >::iterator it = m_areaLocMap.begin();
|
||||
while (it != m_areaLocMap.end()) {
|
||||
if(it.key()<= 0)
|
||||
{
|
||||
QVector<int> locVec = it.value();
|
||||
for(int index(0);index<locVec.size();index++)
|
||||
{
|
||||
if(locVec.at(index) == it.key())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QTreeWidgetItem *firstItem = new QTreeWidgetItem();
|
||||
firstItem->setText(0,getDescByAreaId(locVec.at(index)));
|
||||
firstItem->setData(0,Qt::UserRole,locVec.at(index));
|
||||
firstItem->setData(0,Qt::UserRole+1,it.key());
|
||||
firstItem->setCheckState(0,Qt::Unchecked);
|
||||
firstItem->setToolTip(0,getDescByAreaId(locVec.at(index)));
|
||||
ui->area->addTopLevelItem(firstItem);
|
||||
}
|
||||
}else
|
||||
{
|
||||
QTreeWidgetItem *firstItem = new QTreeWidgetItem();
|
||||
firstItem->setText(0,getDescByAreaId(it.key()));
|
||||
firstItem->setData(0,Qt::UserRole,it.key());
|
||||
firstItem->setData(0,Qt::UserRole+1,-1);
|
||||
firstItem->setCheckState(0,Qt::Unchecked);
|
||||
firstItem->setToolTip(0,getDescByAreaId(it.key()));
|
||||
QVector<int> locVec = it.value();
|
||||
for(int index(0);index<locVec.size();index++)
|
||||
{
|
||||
if(locVec.at(index) == it.key())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QTreeWidgetItem *secondItem = new QTreeWidgetItem();
|
||||
secondItem->setText(0,getDescByAreaId(locVec.at(index)));
|
||||
secondItem->setData(0,Qt::UserRole,locVec.at(index));
|
||||
secondItem->setData(0,Qt::UserRole+1,it.key());
|
||||
secondItem->setCheckState(0,Qt::Unchecked);
|
||||
secondItem->setToolTip(0,getDescByAreaId(locVec.at(index)));
|
||||
firstItem->addChild(secondItem);
|
||||
}
|
||||
ui->area->addTopLevelItem(firstItem);
|
||||
isArea = true;
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
//< 无区域配置时不缩进,尽可能展示完全
|
||||
if(!isArea)
|
||||
{
|
||||
ui->area->setIndentation(0);
|
||||
}
|
||||
foreach (QString value, m_regionMap)
|
||||
{
|
||||
ui->region->addItem(value);
|
||||
}
|
||||
|
||||
foreach (QString value, m_alarmStatusMap)
|
||||
{
|
||||
ui->status->addItem(value);
|
||||
}
|
||||
|
||||
iot_public::CSysInfoInterfacePtr spSysInfo;
|
||||
if (iot_public::createSysInfoInstance(spSysInfo))
|
||||
{
|
||||
std::vector<iot_public::SSubsystemInfo> vecSubsystemInfo;
|
||||
spSysInfo->getAllSubsystemInfo(vecSubsystemInfo);
|
||||
foreach (iot_public::SSubsystemInfo info, vecSubsystemInfo)
|
||||
{
|
||||
if(info.nId <= CN_AppId_COMAPP)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ui->subSystem->addItem(QString::fromStdString(info.strDesc));
|
||||
}
|
||||
}
|
||||
ui->subSystem->setCurrentIndex(-1);
|
||||
|
||||
|
||||
connect(ui->ok, SIGNAL(clicked()), this, SLOT(slot_updateFilter()));
|
||||
connect(ui->cancle, SIGNAL(clicked()), this, SLOT(reject()));
|
||||
connect(ui->checkLevel, SIGNAL(pressed()), this, SLOT(slot_checkLevelPressed()));
|
||||
connect(ui->checkLevel, SIGNAL(stateChanged(int)), this, SLOT(slot_levelSelectChange(int)));
|
||||
connect(ui->level, SIGNAL(itemSelectionChanged()), this, SLOT(slot_updateCheckLevelState()));
|
||||
connect(ui->checkLocation, SIGNAL(pressed()), this, SLOT(slot_checkLocationPressed()));
|
||||
connect(ui->checkLocation, SIGNAL(stateChanged(int)), this, SLOT(slot_locationSelectChange(int)));
|
||||
connect(ui->area,&QTreeWidget::itemChanged, this, &CAlarmFilterDialog::slot_updateCheckLocationState);
|
||||
connect(ui->checkRegion, SIGNAL(pressed()), this, SLOT(slot_checkRegionPressed()));
|
||||
connect(ui->checkRegion, SIGNAL(stateChanged(int)), this, SLOT(slot_regionSelectChange(int)));
|
||||
connect(ui->region, SIGNAL(itemSelectionChanged()), this, SLOT(slot_updateCheckRegionState()));
|
||||
connect(ui->checkStatus, SIGNAL(pressed()), this, SLOT(slot_checkStatusPressed()));
|
||||
connect(ui->checkStatus, SIGNAL(stateChanged(int)), this, SLOT(slot_statusSelectChange(int)));
|
||||
connect(ui->status, SIGNAL(itemSelectionChanged()), this, SLOT(slot_updateCheckStatusState()));
|
||||
connect(ui->subSystem, SIGNAL(currentIndexChanged(QString)), this, SLOT(slot_updateDevice(QString)));
|
||||
if(ui->subSystem->count() > 0)
|
||||
{
|
||||
ui->subSystem->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setLevelFilterEnable(const bool &isLevelFilterEnable)
|
||||
{
|
||||
ui->levelFilter->setChecked(isLevelFilterEnable);
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setLevelFilter(const QList<int> &filter)
|
||||
{
|
||||
for(int nIndex(0); nIndex < ui->level->count(); nIndex++)
|
||||
{
|
||||
int nLevelID = m_priorityMap.key(ui->level->item(nIndex)->text());
|
||||
if(filter.contains(nLevelID))
|
||||
{
|
||||
ui->level->item(nIndex)->setSelected(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->level->item(nIndex)->setSelected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setLocationFilterEnable(const bool &isLocationFilterEnable)
|
||||
{
|
||||
ui->locationFilter->setChecked(isLocationFilterEnable);
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setLocationFilter(const QList<int> &filter)
|
||||
{
|
||||
if(filter.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
ui->area->blockSignals(true);
|
||||
int count = ui->area->topLevelItemCount();
|
||||
for(int index(0);index<count;index++)
|
||||
{
|
||||
QTreeWidgetItem *firstItem = ui->area->topLevelItem(index);
|
||||
int areaId = firstItem->data(0,Qt::UserRole).toInt();
|
||||
if(filter.contains(areaId))
|
||||
{
|
||||
firstItem->setCheckState(0,Qt::Checked);
|
||||
}
|
||||
int childCount = firstItem->childCount();
|
||||
|
||||
for(int locIndex(0);locIndex <childCount;locIndex++)
|
||||
{
|
||||
QTreeWidgetItem *secondItem = firstItem->child(locIndex);
|
||||
int locId = secondItem->data(0,Qt::UserRole).toInt();
|
||||
if(filter.contains(locId))
|
||||
{
|
||||
secondItem->setCheckState(0,Qt::Checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
int selectNum = 0;
|
||||
int allNum = 0;
|
||||
for(int index(0);index<count;index++)
|
||||
{
|
||||
allNum++;
|
||||
QTreeWidgetItem *firstItem =ui->area->topLevelItem(index);
|
||||
if(firstItem->checkState(0) == Qt::Checked)
|
||||
{
|
||||
selectNum += 1;
|
||||
}
|
||||
int childNum = firstItem->childCount();
|
||||
for(int secIndex(0);secIndex<childNum;secIndex++)
|
||||
{
|
||||
QTreeWidgetItem *secondItem = firstItem->child(secIndex);
|
||||
allNum++;
|
||||
if(secondItem->checkState(0) == Qt::Checked)
|
||||
{
|
||||
selectNum += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(selectNum == 0)
|
||||
{
|
||||
ui->checkLocation->setCheckState(Qt::Unchecked);
|
||||
}else if(selectNum == allNum)
|
||||
{
|
||||
ui->checkLocation->setCheckState(Qt::Checked);
|
||||
}else
|
||||
{
|
||||
ui->checkLocation->setCheckState(Qt::PartiallyChecked);
|
||||
}
|
||||
ui->area->blockSignals(false);
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setRegionFilterEnable(const bool &isRegionFilterEnable)
|
||||
{
|
||||
ui->regionFilter->setChecked(isRegionFilterEnable);
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setRegionFilter(const QList<int> &filter)
|
||||
{
|
||||
for(int nIndex(0); nIndex < ui->region->count(); nIndex++)
|
||||
{
|
||||
int nRegionID = m_regionMap.key(ui->region->item(nIndex)->text());
|
||||
if(filter.contains(nRegionID))
|
||||
{
|
||||
ui->region->item(nIndex)->setSelected(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->region->item(nIndex)->setSelected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setAlarmStatusFilterEnable(const bool &isAlarmStatusEnable)
|
||||
{
|
||||
ui->alarmStatusFilter->setChecked(isAlarmStatusEnable);
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setAlarmStatusFilter(const QList<int> &filter)
|
||||
{
|
||||
for(int nIndex(0); nIndex < ui->status->count(); nIndex++)
|
||||
{
|
||||
int nAlarmTypeID = m_alarmStatusMap.key(ui->status->item(nIndex)->text());
|
||||
if(filter.contains(nAlarmTypeID))
|
||||
{
|
||||
ui->status->item(nIndex)->setSelected(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->status->item(nIndex)->setSelected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setDeviceFilterEnable(const bool &filter)
|
||||
{
|
||||
ui->deviceFilterEnable->setChecked(filter);
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setSubSystem(const QString &subSystem)
|
||||
{
|
||||
if(ui->deviceFilterEnable->isChecked())
|
||||
{
|
||||
ui->subSystem->setCurrentText(subSystem);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setDeviceType(const QString &deviceType)
|
||||
{
|
||||
if(ui->deviceFilterEnable->isChecked())
|
||||
{
|
||||
ui->deviceType->setCurrentText(deviceType);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setTimeFilterEnable(const bool &filter)
|
||||
{
|
||||
ui->timeFilterEnable->setChecked(filter);
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setStartTimeFilter(const QDateTime &filter)
|
||||
{
|
||||
if(ui->timeFilterEnable->isChecked())
|
||||
{
|
||||
ui->startTime->setDateTime(filter);
|
||||
}
|
||||
else
|
||||
{
|
||||
QDateTime dataTime(QDateTime::currentDateTime());
|
||||
// dataTime.setTime(QTime(dataTime.time().hour(),dataTime.time().second(),0,0));
|
||||
dataTime.setTime(QTime(dataTime.time().hour(),dataTime.time().minute(),0,0));
|
||||
//dataTime.setTime(QTime(00,00,0,0));
|
||||
ui->startTime->setDateTime(dataTime);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setEndTimeFilter(const QDateTime &filter)
|
||||
{
|
||||
if(ui->timeFilterEnable->isChecked())
|
||||
{
|
||||
ui->endTime->setDateTime(filter);
|
||||
}
|
||||
else
|
||||
{
|
||||
QDateTime dataTime(QDateTime::currentDateTime());
|
||||
// dataTime.setTime(QTime(dataTime.time().hour(),dataTime.time().second(),59,999));
|
||||
dataTime.setTime(QTime(dataTime.time().hour(),dataTime.time().minute(),59,999));
|
||||
//dataTime.setTime(QTime(23,59,59,999));
|
||||
|
||||
ui->endTime->setDateTime(dataTime);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setStateFilterEnable(const bool &filter)
|
||||
{
|
||||
ui->stateFilterEnable->setChecked(filter);
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setStateFilter(const bool &filter)
|
||||
{
|
||||
if(filter)
|
||||
{
|
||||
ui->confirm->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->unConfirm->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setkeyWordFilterEnable(const bool &filter)
|
||||
{
|
||||
ui->keywordFilterEnable->setChecked(filter);
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setkeyWordFilteContent(const QString &content)
|
||||
{
|
||||
if(ui->keywordFilterEnable->isChecked())
|
||||
{
|
||||
ui->keyWord->setText(content);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setReturnFilterEnable(const bool &filter)
|
||||
{
|
||||
ui->returnFilterEnable->setChecked(filter);
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::setReturnFilter(const bool &filter)
|
||||
{
|
||||
if(filter)
|
||||
{
|
||||
ui->hasReturn->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->notReturn->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::slot_updateFilter()
|
||||
{
|
||||
bool isLevelFilter = ui->levelFilter->isChecked();
|
||||
QList<int> listLevel;
|
||||
foreach (QListWidgetItem *item, ui->level->selectedItems())
|
||||
{
|
||||
listLevel << m_priorityMap.key(item->text());
|
||||
}
|
||||
|
||||
bool isLocationFilter = ui->locationFilter->isChecked();
|
||||
QList<int> listLocation;
|
||||
|
||||
int count = ui->area->topLevelItemCount();
|
||||
for(int index(0);index<count;index++)
|
||||
{
|
||||
QTreeWidgetItem *firstItem = ui->area->topLevelItem(index);
|
||||
if(firstItem->checkState(0) == Qt::Checked)
|
||||
{
|
||||
listLocation.append(firstItem->data(0,Qt::UserRole).toInt());
|
||||
}
|
||||
int locCount = firstItem->childCount();
|
||||
for(int locIndex(0);locIndex<locCount;locIndex++)
|
||||
{
|
||||
QTreeWidgetItem *secondItem = firstItem->child(locIndex);
|
||||
if(secondItem->checkState(0) == Qt::Checked)
|
||||
{
|
||||
listLocation.append(secondItem->data(0,Qt::UserRole).toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isRegionFilter = ui->regionFilter->isChecked();
|
||||
QList<int> listRegion;
|
||||
foreach (QListWidgetItem *item, ui->region->selectedItems())
|
||||
{
|
||||
listRegion << m_regionMap.key(item->text());
|
||||
}
|
||||
|
||||
bool isAlarmStatusFilter = ui->alarmStatusFilter->isChecked();
|
||||
QList<int> listAlarmStatus;
|
||||
foreach (QListWidgetItem *item, ui->status->selectedItems())
|
||||
{
|
||||
listAlarmStatus << m_alarmStatusMap.key(item->text());
|
||||
}
|
||||
|
||||
bool isDeviceTypeFilter = ui->deviceFilterEnable->isChecked();
|
||||
QString subSystem = ui->subSystem->currentText();
|
||||
QString deviceType = ui->deviceType->currentText();
|
||||
|
||||
bool isKeyWordFilter = ui->keywordFilterEnable->isChecked();
|
||||
QString strKeyWord =ui->keyWord->text();
|
||||
|
||||
bool isTimeFilter = ui->timeFilterEnable->isChecked();
|
||||
QDateTime startTime = QDateTime();
|
||||
QDateTime endTime = QDateTime();
|
||||
if(isTimeFilter)
|
||||
{
|
||||
startTime = ui->startTime->dateTime();
|
||||
endTime = ui->endTime->dateTime();
|
||||
if(endTime.toTime_t() < startTime.toTime_t())
|
||||
{
|
||||
QMessageBox::warning(this, tr("提示"), tr("结束时间大于开始时间!"), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool isConfirmFilter = ui->stateFilterEnable->isChecked();
|
||||
bool confirm = ui->confirm->isChecked();
|
||||
bool isReturnFilter =ui->returnFilterEnable->isChecked();
|
||||
bool breturn = ui->hasReturn->isChecked();
|
||||
|
||||
emit sig_updateFilter(isLevelFilter, listLevel, isLocationFilter, listLocation, isRegionFilter, listRegion, isAlarmStatusFilter, listAlarmStatus,
|
||||
isDeviceTypeFilter, subSystem, deviceType, isKeyWordFilter, strKeyWord, isTimeFilter, startTime, endTime, isConfirmFilter, confirm,isReturnFilter,breturn);
|
||||
accept();
|
||||
}
|
||||
|
||||
//Level
|
||||
void CAlarmFilterDialog::slot_checkLevelPressed()
|
||||
{
|
||||
if( Qt::Unchecked == ui->checkLevel->checkState())
|
||||
{
|
||||
ui->checkLevel->setTristate(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::slot_levelSelectChange(const int &state)
|
||||
{
|
||||
if( Qt::Unchecked == (Qt::CheckState)state )
|
||||
{
|
||||
ui->level->clearSelection();
|
||||
}
|
||||
else if( Qt::Checked == (Qt::CheckState)state)
|
||||
{
|
||||
ui->level->selectAll();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::slot_updateCheckLevelState()
|
||||
{
|
||||
if( ui->level->count() == ui->level->selectedItems().count() )
|
||||
{
|
||||
if( Qt::Checked != ui->checkLevel->checkState() )
|
||||
{
|
||||
ui->checkLevel->setCheckState(Qt::Checked);
|
||||
}
|
||||
|
||||
}
|
||||
else if( 0 == ui->level->selectedItems().count() )
|
||||
{
|
||||
if( Qt::Unchecked != ui->checkLevel->checkState() )
|
||||
{
|
||||
ui->checkLevel->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Qt::PartiallyChecked != ui->checkLevel->checkState() )
|
||||
{
|
||||
ui->checkLevel->setCheckState(Qt::PartiallyChecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Location
|
||||
void CAlarmFilterDialog::slot_checkLocationPressed()
|
||||
{
|
||||
if( Qt::Unchecked == ui->checkLocation->checkState())
|
||||
{
|
||||
ui->checkLocation->setTristate(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::slot_locationSelectChange(const int &state)
|
||||
{
|
||||
if( Qt::Unchecked == (Qt::CheckState)state )
|
||||
{
|
||||
clearTreeSelection();
|
||||
}
|
||||
else if( Qt::Checked == (Qt::CheckState)state)
|
||||
{
|
||||
allTreeSelection();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::slot_updateCheckLocationState(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
Q_UNUSED(column);
|
||||
ui->area->blockSignals(true);
|
||||
if(item->parent() == NULL) //父节点
|
||||
{
|
||||
childItemSelection(item);
|
||||
}else if(item->childCount()<= 0) //子节点
|
||||
{
|
||||
//parentItemSelection(item);
|
||||
}
|
||||
|
||||
int selectNum = 0;
|
||||
int count = ui->area->topLevelItemCount();
|
||||
int allNum = 0;
|
||||
for(int index(0);index<count;index++)
|
||||
{
|
||||
allNum++;
|
||||
QTreeWidgetItem *firstItem =ui->area->topLevelItem(index);
|
||||
if(firstItem->checkState(0) == Qt::Checked)
|
||||
{
|
||||
selectNum += 1;
|
||||
}
|
||||
int childNum = firstItem->childCount();
|
||||
for(int secIndex(0);secIndex<childNum;secIndex++)
|
||||
{
|
||||
QTreeWidgetItem *secondItem = firstItem->child(secIndex);
|
||||
allNum++;
|
||||
if(secondItem->checkState(0) == Qt::Checked)
|
||||
{
|
||||
selectNum += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(selectNum == 0)
|
||||
{
|
||||
ui->checkLocation->setCheckState(Qt::Unchecked);
|
||||
}else if(selectNum == allNum)
|
||||
{
|
||||
ui->checkLocation->setCheckState(Qt::Checked);
|
||||
}else
|
||||
{
|
||||
ui->checkLocation->setCheckState(Qt::PartiallyChecked);
|
||||
}
|
||||
|
||||
|
||||
ui->area->blockSignals(false);
|
||||
}
|
||||
|
||||
//Region
|
||||
void CAlarmFilterDialog::slot_checkRegionPressed()
|
||||
{
|
||||
if( Qt::Unchecked == ui->checkRegion->checkState())
|
||||
{
|
||||
ui->checkRegion->setTristate(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::slot_regionSelectChange(const int &state)
|
||||
{
|
||||
if( Qt::Unchecked == (Qt::CheckState)state )
|
||||
{
|
||||
ui->region->clearSelection();
|
||||
}
|
||||
else if( Qt::Checked == (Qt::CheckState)state)
|
||||
{
|
||||
ui->region->selectAll();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::slot_updateCheckRegionState()
|
||||
{
|
||||
if( ui->region->count() == ui->region->selectedItems().count() )
|
||||
{
|
||||
if( Qt::Checked != ui->checkRegion->checkState() )
|
||||
{
|
||||
ui->checkRegion->setCheckState(Qt::Checked);
|
||||
}
|
||||
|
||||
}
|
||||
else if( 0 == ui->region->selectedItems().count() )
|
||||
{
|
||||
if( Qt::Unchecked != ui->checkRegion->checkState() )
|
||||
{
|
||||
ui->checkRegion->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Qt::PartiallyChecked != ui->checkRegion->checkState() )
|
||||
{
|
||||
ui->checkRegion->setCheckState(Qt::PartiallyChecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Type
|
||||
void CAlarmFilterDialog::slot_checkStatusPressed()
|
||||
{
|
||||
if( Qt::Unchecked == ui->checkStatus->checkState())
|
||||
{
|
||||
ui->checkStatus->setTristate(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::slot_statusSelectChange(const int &state)
|
||||
{
|
||||
if( Qt::Unchecked == (Qt::CheckState)state )
|
||||
{
|
||||
ui->status->clearSelection();
|
||||
}
|
||||
else if( Qt::Checked == (Qt::CheckState)state)
|
||||
{
|
||||
ui->status->selectAll();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::slot_updateCheckStatusState()
|
||||
{
|
||||
if( ui->status->count() == ui->status->selectedItems().count() )
|
||||
{
|
||||
if( Qt::Checked != ui->checkStatus->checkState() )
|
||||
{
|
||||
ui->checkStatus->setCheckState(Qt::Checked);
|
||||
}
|
||||
|
||||
}
|
||||
else if( 0 == ui->status->selectedItems().count() )
|
||||
{
|
||||
if( Qt::Unchecked != ui->checkStatus->checkState() )
|
||||
{
|
||||
ui->checkStatus->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Qt::PartiallyChecked != ui->checkStatus->checkState() )
|
||||
{
|
||||
ui->checkStatus->setCheckState(Qt::PartiallyChecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::slot_updateDevice(const QString &subSystem)
|
||||
{
|
||||
int nSubSystemId = -1;
|
||||
iot_public::CSysInfoInterfacePtr spSysInfo;
|
||||
if (iot_public::createSysInfoInstance(spSysInfo))
|
||||
{
|
||||
std::vector<iot_public::SSubsystemInfo> vecSubsystemInfo;
|
||||
spSysInfo->getAllSubsystemInfo(vecSubsystemInfo);
|
||||
foreach (iot_public::SSubsystemInfo info, vecSubsystemInfo)
|
||||
{
|
||||
if(subSystem.toStdString() == info.strDesc)
|
||||
{
|
||||
nSubSystemId = info.nId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ui->deviceType->clear();
|
||||
|
||||
QList<iot_dbms::CVarType> values;
|
||||
|
||||
if(nSubSystemId != -1)
|
||||
{
|
||||
iot_dbms::CVarType subSystemId = nSubSystemId;
|
||||
if(m_rtdbAccess->open("base", "dev_type_def"))
|
||||
{
|
||||
iot_dbms::CTableLockGuard locker(*m_rtdbAccess);
|
||||
iot_dbms::CONDINFO condition;
|
||||
condition.relationop = ATTRCOND_EQU;
|
||||
memcpy(condition.name, "sub_system", strlen("sub_system") );
|
||||
condition.conditionval = subSystemId;
|
||||
std::vector<std::string> columns;
|
||||
columns.push_back("description");
|
||||
|
||||
iot_dbms::CRdbQueryResult result;
|
||||
if(m_rtdbAccess->select(condition, result, columns))
|
||||
{
|
||||
for(int nIndex(0); nIndex < result.getRecordCount(); nIndex++)
|
||||
{
|
||||
iot_dbms::CVarType value;
|
||||
result.getColumnValue(nIndex, 0, value);
|
||||
values.append(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (iot_dbms::CVarType value, values)
|
||||
{
|
||||
ui->deviceType->addItem(value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
QString CAlarmFilterDialog::getDescByAreaId(int areaId)
|
||||
{
|
||||
SAreaInfo info;
|
||||
return m_areaInfoMap.value(areaId,info).stDes;
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::clearTreeSelection()
|
||||
{
|
||||
int count = ui->area->topLevelItemCount();
|
||||
for(int index(0);index<count;index++)
|
||||
{
|
||||
ui->area->topLevelItem(index)->setCheckState(0,Qt::Unchecked);
|
||||
slot_updateCheckLocationState(ui->area->topLevelItem(index),0);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::childItemSelection(QTreeWidgetItem *item)
|
||||
{
|
||||
Qt::CheckState status = item->checkState(0);
|
||||
|
||||
int count = item->childCount();
|
||||
for(int index(0);index<count;index++)
|
||||
{
|
||||
item->child(index)->setCheckState(0,status);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::parentItemSelection(QTreeWidgetItem *item)
|
||||
{
|
||||
QTreeWidgetItem *parent = item->parent();
|
||||
int count = parent->childCount();
|
||||
int checkNum = 0;
|
||||
for(int index(0);index<count;index++)
|
||||
{
|
||||
if(parent->child(index)->checkState(0) == Qt::Checked)
|
||||
{
|
||||
checkNum += 1;
|
||||
}
|
||||
}
|
||||
if(checkNum == count)
|
||||
{
|
||||
parent->setCheckState(0,Qt::Checked);
|
||||
}else if(checkNum == 0)
|
||||
{
|
||||
parent->setCheckState(0,Qt::Unchecked);
|
||||
}else
|
||||
{
|
||||
parent->setCheckState(0,Qt::PartiallyChecked);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmFilterDialog::allTreeSelection()
|
||||
{
|
||||
int count = ui->area->topLevelItemCount();
|
||||
for(int index(0);index<count;index++)
|
||||
{
|
||||
ui->area->topLevelItem(index)->setCheckState(0,Qt::Checked);
|
||||
slot_updateCheckLocationState(ui->area->topLevelItem(index),0);
|
||||
}
|
||||
}
|
||||
123
product/src/gui/plugin/AlarmWidget_pad/CAlarmFilterDialog.h
Normal file
123
product/src/gui/plugin/AlarmWidget_pad/CAlarmFilterDialog.h
Normal file
@ -0,0 +1,123 @@
|
||||
#ifndef CALARMFILTERDIALOG_H
|
||||
#define CALARMFILTERDIALOG_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QDialog>
|
||||
#include <QDateTime>
|
||||
#include "dbms/rdb_api/CRdbAccess.h"
|
||||
#include "CAlarmCommon.h"
|
||||
|
||||
class QTreeWidgetItem;
|
||||
|
||||
namespace Ui {
|
||||
class CAlarmFilterDialog;
|
||||
}
|
||||
|
||||
class CAlarmFilterDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
//Q_PROPERTY(int windowMinWidth READ windowMinWidth WRITE setWindowMinWidth)
|
||||
//Q_PROPERTY(int windowMinHeigth READ windowMinHeigth WRITE setWindowMinHeigth)
|
||||
|
||||
public slots:
|
||||
int windowMinWidth();
|
||||
void setWindowMinWidth(int nWidth);
|
||||
int windowMinHeigth();
|
||||
void setWindowMinHeigth(int nHeight);
|
||||
|
||||
public:
|
||||
explicit CAlarmFilterDialog(QWidget *parent = 0);
|
||||
~CAlarmFilterDialog();
|
||||
|
||||
void initialize();
|
||||
void setLevelFilterEnable(const bool &isLevelFilterEnable);
|
||||
void setLevelFilter(const QList<int> &filter);
|
||||
void setLocationFilterEnable(const bool &isLocationFilterEnable);
|
||||
void setLocationFilter(const QList<int> &filter);
|
||||
|
||||
void setRegionFilterEnable(const bool &isRegionFilterEnable);
|
||||
void setRegionFilter(const QList<int> &filter);
|
||||
/**
|
||||
* @brief setAlarmTypeFilterEnable 过滤窗新增告警状态代替告警类型
|
||||
* @param isAlarmTypeEnable
|
||||
*/
|
||||
void setAlarmStatusFilterEnable(const bool &isAlarmStatusEnable);
|
||||
/**
|
||||
* @brief setAlarmStatusFilter 过滤窗新增告警状态代替告警类型
|
||||
* @param filter
|
||||
*/
|
||||
void setAlarmStatusFilter(const QList<int> &filter);
|
||||
|
||||
void setDeviceFilterEnable(const bool &filter);
|
||||
void setSubSystem(const QString &subSystem);
|
||||
void setDeviceType(const QString &deviceType);
|
||||
void setTimeFilterEnable(const bool &filter);
|
||||
void setStartTimeFilter(const QDateTime &filter);
|
||||
void setEndTimeFilter(const QDateTime &filter);
|
||||
void setStateFilterEnable(const bool &filter);
|
||||
void setStateFilter(const bool &filter);
|
||||
void setkeyWordFilterEnable(const bool &filter);
|
||||
void setkeyWordFilteContent(const QString &content);
|
||||
void setReturnFilterEnable(const bool &filter);
|
||||
void setReturnFilter(const bool &filter);
|
||||
signals:
|
||||
/**
|
||||
* @brief sig_updateFilter
|
||||
* @param List level location region alarmType isKeyWordFilterEnable, keyWord, isTimeFilter startTime endTime isConfirmFilter confirm
|
||||
*/
|
||||
void sig_updateFilter(bool, QList<int>, bool, QList<int>, bool, QList<int>, bool, QList<int>, bool, QString, QString, bool, QString, bool, QDateTime, QDateTime, bool, bool,bool,bool);
|
||||
|
||||
private slots:
|
||||
void slot_updateFilter();
|
||||
|
||||
//Level
|
||||
void slot_checkLevelPressed();
|
||||
void slot_levelSelectChange(const int &state);
|
||||
void slot_updateCheckLevelState();
|
||||
|
||||
//Station
|
||||
void slot_checkLocationPressed();
|
||||
void slot_locationSelectChange(const int &state);
|
||||
void slot_updateCheckLocationState(QTreeWidgetItem *item, int column);
|
||||
|
||||
//Region
|
||||
void slot_checkRegionPressed();
|
||||
void slot_regionSelectChange(const int &state);
|
||||
void slot_updateCheckRegionState();
|
||||
|
||||
//AlarmStatus
|
||||
void slot_checkStatusPressed();
|
||||
void slot_statusSelectChange(const int &state);
|
||||
void slot_updateCheckStatusState();
|
||||
|
||||
//DeviceType
|
||||
void slot_updateDevice(const QString &subSystem);
|
||||
|
||||
private:
|
||||
QString getDescByAreaId(int areaId);
|
||||
void clearTreeSelection();
|
||||
void childItemSelection(QTreeWidgetItem *item);
|
||||
void parentItemSelection(QTreeWidgetItem *item);
|
||||
void allTreeSelection();
|
||||
private:
|
||||
Ui::CAlarmFilterDialog *ui;
|
||||
|
||||
iot_dbms::CRdbAccess * m_rtdbAccess;
|
||||
QMap<int, QString> m_priorityMap;
|
||||
QMap<int, QString> m_locationMap;
|
||||
QMap<int, QString> m_regionMap;
|
||||
QMap<int, QString> m_alarmTypeMap;
|
||||
/**
|
||||
* @brief m_alarmStatusMap 过滤窗新增告警状态代替告警类型
|
||||
*/
|
||||
QMap<int, QString> m_alarmStatusMap;
|
||||
|
||||
QMap<int,SAreaInfo> m_areaInfoMap; //区域信息
|
||||
|
||||
QMap<int,QVector<int> > m_areaLocMap; //区域映射
|
||||
|
||||
int m_nMinWidth;
|
||||
int m_nMinHeight;
|
||||
};
|
||||
|
||||
#endif // ALARMFILTERDIALOG_H
|
||||
546
product/src/gui/plugin/AlarmWidget_pad/CAlarmFilterDialog.ui
Normal file
546
product/src/gui/plugin/AlarmWidget_pad/CAlarmFilterDialog.ui
Normal file
@ -0,0 +1,546 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAlarmFilterDialog</class>
|
||||
<widget class="QDialog" name="CAlarmFilterDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>736</width>
|
||||
<height>355</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>过滤</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0" rowspan="2" colspan="7">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_11">
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="deviceFilterEnable">
|
||||
<property name="title">
|
||||
<string>设备类型</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="subSystem">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="deviceType">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="timeFilterEnable">
|
||||
<property name="title">
|
||||
<string>时间</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<item row="0" column="2">
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>结束时间</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDateTimeEdit" name="endTime">
|
||||
<property name="date">
|
||||
<date>
|
||||
<year>2018</year>
|
||||
<month>1</month>
|
||||
<day>1</day>
|
||||
</date>
|
||||
</property>
|
||||
<property name="maximumDate">
|
||||
<date>
|
||||
<year>2050</year>
|
||||
<month>12</month>
|
||||
<day>31</day>
|
||||
</date>
|
||||
</property>
|
||||
<property name="minimumDate">
|
||||
<date>
|
||||
<year>2000</year>
|
||||
<month>1</month>
|
||||
<day>1</day>
|
||||
</date>
|
||||
</property>
|
||||
<property name="displayFormat">
|
||||
<string>yyyy/MM/dd hh:mm</string>
|
||||
</property>
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<item row="1" column="0">
|
||||
<widget class="QDateTimeEdit" name="startTime">
|
||||
<property name="dateTime">
|
||||
<datetime>
|
||||
<hour>0</hour>
|
||||
<minute>0</minute>
|
||||
<second>0</second>
|
||||
<year>2018</year>
|
||||
<month>1</month>
|
||||
<day>1</day>
|
||||
</datetime>
|
||||
</property>
|
||||
<property name="date">
|
||||
<date>
|
||||
<year>2018</year>
|
||||
<month>1</month>
|
||||
<day>1</day>
|
||||
</date>
|
||||
</property>
|
||||
<property name="maximumDateTime">
|
||||
<datetime>
|
||||
<hour>23</hour>
|
||||
<minute>59</minute>
|
||||
<second>59</second>
|
||||
<year>2050</year>
|
||||
<month>12</month>
|
||||
<day>31</day>
|
||||
</datetime>
|
||||
</property>
|
||||
<property name="maximumDate">
|
||||
<date>
|
||||
<year>2050</year>
|
||||
<month>12</month>
|
||||
<day>31</day>
|
||||
</date>
|
||||
</property>
|
||||
<property name="minimumDate">
|
||||
<date>
|
||||
<year>2000</year>
|
||||
<month>1</month>
|
||||
<day>1</day>
|
||||
</date>
|
||||
</property>
|
||||
<property name="displayFormat">
|
||||
<string>yyyy/MM/dd hh:mm</string>
|
||||
</property>
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>开始时间</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_15">
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>281</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="cancle">
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="ok">
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QGroupBox" name="levelFilter">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>优先级</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QListWidget" name="level"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkLevel">
|
||||
<property name="text">
|
||||
<string>全选</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tristate">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QGroupBox" name="locationFilter">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>位置</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeWidget" name="area">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkLocation">
|
||||
<property name="text">
|
||||
<string>全选</string>
|
||||
</property>
|
||||
<property name="tristate">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QGroupBox" name="regionFilter">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>责任区</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QListWidget" name="region"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkRegion">
|
||||
<property name="text">
|
||||
<string>全选</string>
|
||||
</property>
|
||||
<property name="tristate">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QGroupBox" name="alarmStatusFilter">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>告警状态</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkStatus">
|
||||
<property name="text">
|
||||
<string>全选</string>
|
||||
</property>
|
||||
<property name="tristate">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QListWidget" name="status"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="6">
|
||||
<widget class="QGroupBox" name="keywordFilterEnable">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>告警内容关键字</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="keyWord"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="6">
|
||||
<widget class="QGroupBox" name="stateFilterEnable">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>状态</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_12">
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="unConfirm">
|
||||
<property name="text">
|
||||
<string>未确认</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="confirm">
|
||||
<property name="text">
|
||||
<string>已确认</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="5">
|
||||
<widget class="QGroupBox" name="returnFilterEnable">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>复归</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_17">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="hasReturn">
|
||||
<property name="text">
|
||||
<string>已复归</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="notReturn">
|
||||
<property name="text">
|
||||
<string>未复归</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>stateFilterEnable</zorder>
|
||||
<zorder>returnFilterEnable</zorder>
|
||||
<zorder>regionFilter</zorder>
|
||||
<zorder>locationFilter</zorder>
|
||||
<zorder>levelFilter</zorder>
|
||||
<zorder>keywordFilterEnable</zorder>
|
||||
<zorder>alarmStatusFilter</zorder>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
3370
product/src/gui/plugin/AlarmWidget_pad/CAlarmForm.cpp
Normal file
3370
product/src/gui/plugin/AlarmWidget_pad/CAlarmForm.cpp
Normal file
File diff suppressed because it is too large
Load Diff
296
product/src/gui/plugin/AlarmWidget_pad/CAlarmForm.h
Normal file
296
product/src/gui/plugin/AlarmWidget_pad/CAlarmForm.h
Normal file
@ -0,0 +1,296 @@
|
||||
#ifndef CALARMFORM_H
|
||||
#define CALARMFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDateTime>
|
||||
#include <QItemSelection>
|
||||
#include "CAlarmMsgInfo.h"
|
||||
#include "CAiAlarmMsgInfo.h"
|
||||
#include <QListWidget>
|
||||
#include <QLineEdit>
|
||||
#include "CMyCalendar.h"
|
||||
#include <QMenu>
|
||||
#include <QWidgetAction>
|
||||
#include <QDate>
|
||||
#include <QThread>
|
||||
#include <CPdfPrinter.h>
|
||||
#include <QStandardItem>
|
||||
#include <QTableWidgetItem>
|
||||
#include "dbms/db_api_ex/CDbApi.h"
|
||||
|
||||
#include "net/net_msg_bus_api/MsgBusApi.h"
|
||||
#include "net/net_msg_bus_api/CMbCommunicator.h"
|
||||
#include "service/operate_server_api/JsonMessageStruct.h"
|
||||
#include "service/operate_server_api/JsonOptCommand.h"
|
||||
#include "common/MessageChannel.h"
|
||||
#include "public/pub_sysinfo_api/SysInfoApi.h"
|
||||
|
||||
namespace Ui {
|
||||
class CAlarmForm;
|
||||
}
|
||||
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
class QTreeWidgetItem;
|
||||
class CAlarmItemModel;
|
||||
class CAlarmDelegate;
|
||||
class CAiAlarmDelegate;
|
||||
class CAlarmDeviceTreeModel;
|
||||
class CAiAlarmTreeModel;
|
||||
class CAiAlarmTreeView;
|
||||
class CAlarmView;
|
||||
typedef QList<QModelIndex> QModelIndexList;
|
||||
|
||||
|
||||
class CAlarmForm : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CAlarmForm(QWidget *parent = 0);
|
||||
~CAlarmForm();
|
||||
|
||||
void modeConfirm(const int &x);
|
||||
|
||||
void initialize();
|
||||
|
||||
void init();
|
||||
|
||||
void setAlarmModel(CAlarmItemModel * model, CAiAlarmTreeModel *treeModel);
|
||||
|
||||
void setAlarmModel(CAlarmItemModel * model);
|
||||
void updateView();
|
||||
void updateAlarmOperatePerm(); //更新原始告警权限和智能告警操作权限
|
||||
|
||||
void setAlarmOperateEnable(const bool &bEnable);
|
||||
|
||||
void setColumnWidth(const int &column, const int &width);
|
||||
|
||||
void setColumnVisible(const int &column, const bool &visible);
|
||||
|
||||
void setEnableAccidentReview(bool isNeed);
|
||||
|
||||
void setEnableTrend(bool isNeed);
|
||||
|
||||
void setEnableVideo(bool isNeed);
|
||||
|
||||
void setEnableWave(bool isNeed);
|
||||
|
||||
void setEnableLevel(bool isNeed);
|
||||
|
||||
void setHiddenLocation(bool hide);
|
||||
|
||||
void setHiddenTime(bool hide);
|
||||
|
||||
void setHiddenStatus(bool hide);
|
||||
|
||||
void setHiddenPriority(bool hide);
|
||||
|
||||
void setHiddenCheckBox(bool hide);
|
||||
|
||||
void setHiddenSetConfig(bool hide);
|
||||
|
||||
void setHiddenCloseButton(bool hide);
|
||||
|
||||
void setHiddenInhiAlarmButton(bool hide);
|
||||
|
||||
void setHiddenSelectButton(bool hide);
|
||||
|
||||
void setHiddenLeftTree();
|
||||
|
||||
void setShowAiAlarmView(bool show);
|
||||
|
||||
void setRowHeight(int height);
|
||||
|
||||
void setAccidentReviewPath(const QString& path);
|
||||
|
||||
void removeAllAlarm();
|
||||
|
||||
public:
|
||||
void initFilter();
|
||||
void setLevelComboBox(bool &isLevelFilter,QList<int> &listLevel);
|
||||
void setLocationComboBox(bool &isLocationFilter,QList<int> &listLocation);
|
||||
void setAlarmStatusComboBox(bool &isAlarmTypeFilter,QList<int> &listAlarmStatus);
|
||||
void setAlarmTimeLineEdit(bool &isTimeFilter, QDateTime &startTime, QDateTime &endTime);
|
||||
void reloadDevTree();
|
||||
signals:
|
||||
void sigAudioCuesEnable(bool bEnable);
|
||||
|
||||
void closeBtnClicked();
|
||||
|
||||
void printer(QVector<QString> header,QList<QVector<QString> > data,QString fileName,QVector<bool> columnHidden,QVector<double> columnWidth);
|
||||
void printExcel(CAiAlarmTreeView* view,CAiAlarmTreeModel * model,QString fileName);
|
||||
void printExcelAlm(CAlarmView* view ,CAlarmItemModel * model,QString fileName);
|
||||
|
||||
void openTrend(quint64 time_stamp,QStringList tagList);
|
||||
void openVideo(int domainId,int appId,QString tag,quint64 startTime,quint64 endTime);
|
||||
void openAccidentReview(quint64 starTime,quint64 keepTime,QString graph=QString());
|
||||
protected slots:
|
||||
void updateFilter();
|
||||
void deviceGroupFilterChanged(const QString &device, const bool &checked);
|
||||
void slot_changePage(int i);
|
||||
void slot_updateFilter(bool isLevelFilter, QList<int> listLevel, bool isLocationFilter, QList<int> listLocation, bool isRegionFilter, QList<int> listRegion, bool isAlarmTypeFilter, QList<int> listAlarmType,
|
||||
bool isDeviceTypeFilter, QString subSystem, QString deviceType, bool isKeywordFilterEnable,
|
||||
QString keyword, bool isTimeFilter, QDateTime startTime, QDateTime endTime, bool isConfirmFilter, bool confirm,bool isReturnFilter,bool isReturn);
|
||||
|
||||
void slot_removeAlarm();
|
||||
void slot_confirmAlarm();
|
||||
|
||||
void slot_showInhibitAlarm();
|
||||
|
||||
void slot_showShiledAlarm();
|
||||
|
||||
void slot_showColorSet();
|
||||
void removeInhibitAlarm(QList<AlarmMsgPtr> alarmList);
|
||||
|
||||
void searchDeviceName();
|
||||
|
||||
void updateRowTips();
|
||||
|
||||
void print();
|
||||
void stateChanged1(int state);
|
||||
void stateChanged2(int state);
|
||||
void stateChanged3(int state);
|
||||
void textChanged1(const QString &text);
|
||||
void textChanged2(const QString &text);
|
||||
void textChanged3(const QString &text);
|
||||
void myCalendarHide(QDate startTime, QDate endTime);
|
||||
void myCalendarShow();
|
||||
void cancleTimeFilter();
|
||||
|
||||
void aiAlmDoubleClicked(const QModelIndex &index);
|
||||
|
||||
void printMess(QString fileName);
|
||||
|
||||
void slotInhibitDevGroupAlm(const QString &strDevg, int nDomainId, int nLocationId, int nSubsystemId, int nRegionId);
|
||||
void slotInhibitAlarm();
|
||||
void slotInhibitAlarms(QModelIndex a,bool &flag);
|
||||
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
|
||||
void contextMenuStack0Event(QContextMenuEvent *event);
|
||||
|
||||
void contextMenuStack1Event(QContextMenuEvent *event);
|
||||
|
||||
void loadDeviceGroupFilterWidget();
|
||||
|
||||
void updateDeviceGroupHiddenState();
|
||||
private slots:
|
||||
void on_confirm_clicked();
|
||||
|
||||
void slotALlSel();
|
||||
void slotNoneSel();
|
||||
|
||||
void on_alarmView_doubleClicked(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
//原始告警窗点击打印(打印原始告警)
|
||||
void print0(QString fileName);
|
||||
//智能告警窗点击打印(打印智能和原始告警)
|
||||
void print1(QString fileName);
|
||||
//原始告警窗点击删除(删除原始告警)
|
||||
void removeAlarm0();
|
||||
//智能告警窗点击删除(删除智能告警)
|
||||
void removeAlarm1();
|
||||
//原始告警窗点击确认(确认原始告警)
|
||||
void confirmAlarm0();
|
||||
//智能告警窗点击确认(确认原始告警)
|
||||
void confirmAlarm1();
|
||||
|
||||
void rightConfirm0();
|
||||
|
||||
void rightConfirm1();
|
||||
|
||||
void rightRemove0();
|
||||
|
||||
void rightRemove1();
|
||||
|
||||
void rightMerge1();
|
||||
|
||||
void rightSepr1();
|
||||
|
||||
void rightTrend0();
|
||||
|
||||
void rightTrend1();
|
||||
|
||||
void rightVideo0();
|
||||
|
||||
void rightVideo1();
|
||||
|
||||
void rightFaultRecord0();
|
||||
|
||||
void rightFaultRecord1();
|
||||
|
||||
void rightAccidentReview0();
|
||||
|
||||
void rightAccidentReview1();
|
||||
|
||||
void test(QStringList tagList);
|
||||
|
||||
void inhibitAlm(const AlarmMsgPtr &alm);
|
||||
void inhibitAlm(const AlarmMsgPtr &alm,bool &flag);
|
||||
|
||||
bool permCheck(int location ,int region);
|
||||
|
||||
int createReqHead(SOptReqHead &head, const AlarmMsgPtr &alm);
|
||||
|
||||
private:
|
||||
iot_public::CSysInfoInterfacePtr m_ptrSysInfo;
|
||||
iot_dbms::CDbApi *m_pReadDb;
|
||||
|
||||
QLineEdit * m_pSearchTextEdit;
|
||||
QPushButton * m_pSearchButton;
|
||||
QList<int> m_listRegionOptId;
|
||||
QList<int> m_listLocationOptId;
|
||||
|
||||
QList<int> m_listRegionDelId;
|
||||
QList<int> m_listLocationDelId;
|
||||
bool m_aiOptPerm; //智能告警操作权限
|
||||
|
||||
CAlarmItemModel * m_pModel;
|
||||
CAlarmDelegate * m_delegate;
|
||||
CAiAlarmDelegate * m_aiDelegate;
|
||||
CAlarmDeviceTreeModel * m_pDeviceModel;
|
||||
CAiAlarmTreeModel *m_treeModel;
|
||||
iot_net::CMbCommunicator *m_communicator;
|
||||
int m_userId;
|
||||
std::string m_nodeName;
|
||||
int m_nDomainId;
|
||||
|
||||
QListWidget *m_pListWidget1;
|
||||
QListWidget *m_pListWidget2;
|
||||
QListWidget *m_pListWidget3;
|
||||
|
||||
QLineEdit *m_pLineEdit1;
|
||||
QLineEdit *m_pLineEdit2;
|
||||
QLineEdit *m_pLineEdit3;
|
||||
QList<int> m_priorityList;
|
||||
QList<int> m_locationList;
|
||||
QList<int> m_alarmStatusList;
|
||||
QString m_strText1;
|
||||
QString m_strText2;
|
||||
QString m_strText3;
|
||||
Ui::CAlarmForm *ui;
|
||||
QPushButton *m_timeIcon;
|
||||
|
||||
CMyCalendar * m_myCalendar;
|
||||
QMenu *m_timeMenu;
|
||||
|
||||
QThread *m_thread; //打印线程
|
||||
CPdfPrinter *m_pdfPrinter;
|
||||
bool m_isNormal; //是否正常状态 否代表事故追忆状态
|
||||
bool m_isNeedAccidentReview;
|
||||
|
||||
int modeAll;
|
||||
|
||||
bool m_enableAi;
|
||||
QString m_strAccidenPath;
|
||||
bool m_bPopWindow;
|
||||
|
||||
QString m_searchDeviceName;
|
||||
|
||||
};
|
||||
|
||||
#endif // ALARMFORM_H
|
||||
660
product/src/gui/plugin/AlarmWidget_pad/CAlarmForm.ui
Normal file
660
product/src/gui/plugin/AlarmWidget_pad/CAlarmForm.ui
Normal file
@ -0,0 +1,660 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAlarmForm</class>
|
||||
<widget class="QWidget" name="CAlarmForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1994</width>
|
||||
<height>631</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="inhibit">
|
||||
<property name="text">
|
||||
<string>禁止列表</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="filter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>过滤</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="print">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>导出</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>698</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>当前显示数量:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="showRow">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>55</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>过滤告警数量:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="filterRow">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>55</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>优先级:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>125</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>位置:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>113</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>告警状态:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>138</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>时间:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>智能告警</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>13</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="selectAll">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>全选</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="selectNone">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>全不选</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="confirm">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确认</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="remove">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>删除</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="inhiAlarm">
|
||||
<property name="text">
|
||||
<string>禁止告警</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="set">
|
||||
<property name="text">
|
||||
<string>设置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closeBtn">
|
||||
<property name="text">
|
||||
<string>关闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QSplitter" name="splitter_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="CAlarmDeviceTreeView" name="deviceView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>280</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="headerHidden">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_tree_all_sel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>全勾选</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_tree_none_sel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>全不选</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="CAlarmView" name="alarmView">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="cornerButtonEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="CAiAlarmTreeView" name="aiAlarmTreeView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CAlarmView</class>
|
||||
<extends>QTableView</extends>
|
||||
<header>CAlarmView.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CAlarmDeviceTreeView</class>
|
||||
<extends>QTreeView</extends>
|
||||
<header>CAlarmDeviceTreeView.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CAiAlarmTreeView</class>
|
||||
<extends>QTreeView</extends>
|
||||
<header location="global">CAiAlarmTreeView.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<slots>
|
||||
<slot>updateFilter()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
138
product/src/gui/plugin/AlarmWidget_pad/CAlarmInhibitDialog.cpp
Normal file
138
product/src/gui/plugin/AlarmWidget_pad/CAlarmInhibitDialog.cpp
Normal file
@ -0,0 +1,138 @@
|
||||
#include "CAlarmInhibitDialog.h"
|
||||
#include "ui_CAlarmInhibitDialog.h"
|
||||
#include <QDateTime>
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QDir>
|
||||
#include <QApplication>
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include "pub_utility_api/FileStyle.h"
|
||||
#include "CAlarmBaseData.h"
|
||||
|
||||
CAlarmInhibitDialog::CAlarmInhibitDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CAlarmInhibitDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QString qss = QString();
|
||||
std::string strFullPath = iot_public::CFileStyle::getPathOfStyleFile("public.qss") ;
|
||||
QFile qssfile1(QString::fromStdString(strFullPath));
|
||||
qssfile1.open(QFile::ReadOnly);
|
||||
if (qssfile1.isOpen())
|
||||
{
|
||||
qss += QLatin1String(qssfile1.readAll());
|
||||
qssfile1.close();
|
||||
}
|
||||
strFullPath = iot_public::CFileStyle::getPathOfStyleFile("alarm.qss") ;
|
||||
QFile qssfile2(QString::fromStdString(strFullPath));
|
||||
qssfile2.open(QFile::ReadOnly);
|
||||
if (qssfile2.isOpen())
|
||||
{
|
||||
qss += QLatin1String(qssfile2.readAll());
|
||||
qssfile2.close();
|
||||
}
|
||||
if(!qss.isEmpty())
|
||||
{
|
||||
setStyleSheet(qss);
|
||||
}
|
||||
connect(ui->ok, &QPushButton::clicked, this, &CAlarmInhibitDialog::onRemoveInhibit);
|
||||
connect(ui->cancle, &QPushButton::clicked, [=](){
|
||||
reject();
|
||||
});
|
||||
}
|
||||
|
||||
CAlarmInhibitDialog::~CAlarmInhibitDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CAlarmInhibitDialog::setInhibitAlarmList(const QList<AlarmMsgPtr> &alarmList)
|
||||
{
|
||||
m_inhibitAlarmList = alarmList;
|
||||
ui->tableWidget->setRowCount(m_inhibitAlarmList.size());
|
||||
ui->tableWidget->setColumnCount(7);
|
||||
for(int nRow(0); nRow < m_inhibitAlarmList.size(); nRow++)
|
||||
{
|
||||
QTableWidgetItem *item;
|
||||
QString time_stamp = QDateTime::fromMSecsSinceEpoch(m_inhibitAlarmList.at(nRow)->time_stamp).toString("yyyy-MM-dd hh:mm:ss");
|
||||
item = new QTableWidgetItem(time_stamp);
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tableWidget->setItem(nRow, 0, item);
|
||||
|
||||
QString priority = CAlarmBaseData::instance()->queryPriorityDesc(m_inhibitAlarmList.at(nRow)->priority);
|
||||
item = new QTableWidgetItem(priority);
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tableWidget->setItem(nRow, 1, item);
|
||||
|
||||
QString location = CAlarmBaseData::instance()->queryLocationDesc(m_inhibitAlarmList.at(nRow)->location_id);
|
||||
item = new QTableWidgetItem(location);
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tableWidget->setItem(nRow, 2, item);
|
||||
|
||||
QString region = CAlarmBaseData::instance()->queryRegionDesc(m_inhibitAlarmList.at(nRow)->region_id);
|
||||
item = new QTableWidgetItem(region);
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tableWidget->setItem(nRow, 3, item);
|
||||
|
||||
QString type = CAlarmBaseData::instance()->queryAlarmTypeDesc(m_inhibitAlarmList.at(nRow)->alm_type);
|
||||
item = new QTableWidgetItem(type);
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tableWidget->setItem(nRow, 4, item);
|
||||
|
||||
QString state;
|
||||
if(E_ALS_ALARM == m_inhibitAlarmList.at(nRow)->logic_state || E_ALS_RETURN == m_inhibitAlarmList.at(nRow)->logic_state) //< 未确认
|
||||
{
|
||||
state = tr("未确认");
|
||||
}
|
||||
else
|
||||
{
|
||||
state = tr("已确认");
|
||||
}
|
||||
item = new QTableWidgetItem(state);
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tableWidget->setItem(nRow, 5, item);
|
||||
|
||||
item = new QTableWidgetItem(m_inhibitAlarmList.at(nRow)->content);
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tableWidget->setItem(nRow, 6, item);
|
||||
}
|
||||
|
||||
ui->tableWidget->setColumnWidth(0, 230);
|
||||
ui->tableWidget->setColumnWidth(1, 100);
|
||||
ui->tableWidget->setColumnWidth(2, 150);
|
||||
ui->tableWidget->setColumnWidth(3, 150);
|
||||
ui->tableWidget->setColumnWidth(4, 120);
|
||||
ui->tableWidget->setColumnWidth(5, 80);
|
||||
|
||||
}
|
||||
|
||||
void CAlarmInhibitDialog::onRemoveInhibit()
|
||||
{
|
||||
QModelIndexList indexList = ui->tableWidget->selectionModel()->selectedRows(0);
|
||||
if(indexList.isEmpty())
|
||||
{
|
||||
QMessageBox::information(this, tr("警告"), tr("请选择取消禁止告警所在的行!"), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
std::sort(indexList.begin(), indexList.end());
|
||||
QList<AlarmMsgPtr> removedInhibitAlarmList;
|
||||
for(int nRow(indexList.size() - 1); nRow >= 0; nRow--)
|
||||
{
|
||||
removedInhibitAlarmList.append(m_inhibitAlarmList.takeAt(indexList.at(nRow).row()));
|
||||
ui->tableWidget->removeRow(indexList.at(nRow).row());
|
||||
}
|
||||
emit removeInhibitAlarmList(removedInhibitAlarmList);
|
||||
}
|
||||
|
||||
void CAlarmInhibitDialog::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
QWidget::contextMenuEvent(event);
|
||||
QMenu menu(this);
|
||||
QAction * InhibitAction = menu.addAction(tr("取消禁止告警"));
|
||||
connect(InhibitAction, &QAction::triggered,this,&CAlarmInhibitDialog::onRemoveInhibit);
|
||||
setUpdatesEnabled(false);
|
||||
menu.exec(QCursor::pos());
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
36
product/src/gui/plugin/AlarmWidget_pad/CAlarmInhibitDialog.h
Normal file
36
product/src/gui/plugin/AlarmWidget_pad/CAlarmInhibitDialog.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef CALARMINHIBITDIALOG_H
|
||||
#define CALARMINHIBITDIALOG_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QDialog>
|
||||
#include "CAlarmMsgInfo.h"
|
||||
|
||||
namespace Ui {
|
||||
class CAlarmInhibitDialog;
|
||||
}
|
||||
|
||||
class CAlarmInhibitDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CAlarmInhibitDialog(QWidget *parent = 0);
|
||||
~CAlarmInhibitDialog();
|
||||
|
||||
void setInhibitAlarmList(const QList<AlarmMsgPtr> &alarmList);
|
||||
|
||||
signals:
|
||||
void removeInhibitAlarmList(QList<AlarmMsgPtr> alarmList);
|
||||
|
||||
protected slots:
|
||||
void onRemoveInhibit();
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
|
||||
private:
|
||||
Ui::CAlarmInhibitDialog *ui;
|
||||
|
||||
QList<AlarmMsgPtr> m_inhibitAlarmList;
|
||||
};
|
||||
|
||||
#endif // CALARMINHIBITDIALOG_H
|
||||
135
product/src/gui/plugin/AlarmWidget_pad/CAlarmInhibitDialog.ui
Normal file
135
product/src/gui/plugin/AlarmWidget_pad/CAlarmInhibitDialog.ui
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAlarmInhibitDialog</class>
|
||||
<widget class="QDialog" name="CAlarmInhibitDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1094</width>
|
||||
<height>433</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>禁止告警列表</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="cancle">
|
||||
<property name="text">
|
||||
<string>关闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="ok">
|
||||
<property name="text">
|
||||
<string>取消禁止告警</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::MultiSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>时间</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignLeading|AlignVCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>优先级</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignLeading|AlignVCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>位置</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignLeading|AlignVCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>责任区</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignLeading|AlignVCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>告警类型</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignLeading|AlignVCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>确认状态</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignLeading|AlignVCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>告警内容</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignLeading|AlignVCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
926
product/src/gui/plugin/AlarmWidget_pad/CAlarmItemModel.cpp
Normal file
926
product/src/gui/plugin/AlarmWidget_pad/CAlarmItemModel.cpp
Normal file
@ -0,0 +1,926 @@
|
||||
#include "CAlarmItemModel.h"
|
||||
#include "CAlarmMsgInfo.h"
|
||||
#include <QModelIndex>
|
||||
#include <QHeaderView>
|
||||
#include <QMutexLocker>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include "CAlarmDataCollect.h"
|
||||
#include "CAlarmMsgManage.h"
|
||||
#include "perm_mng_api/PermMngApi.h"
|
||||
#include <QDebug>
|
||||
#include "boost/property_tree/xml_parser.hpp"
|
||||
#include "boost/typeof/typeof.hpp"
|
||||
#include "boost/filesystem.hpp"
|
||||
#include "Common.h"
|
||||
#include "pub_utility_api/FileUtil.h"
|
||||
#include "pub_utility_api/CharUtil.h"
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include <QDomDocument>
|
||||
#include <QFile>
|
||||
#include <QToolTip>
|
||||
#include "CAlarmBaseData.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace iot_public;
|
||||
using namespace std;
|
||||
const int DOCK_ROW_COUNT = 3;
|
||||
const int MAX_ROW_COUNT = 15000;
|
||||
const int ALM_TYPE_SYSTEM = 5; //系统告警信息
|
||||
|
||||
CAlarmItemModel::CAlarmItemModel(E_Alarm_Mode mode, QObject *parent)
|
||||
:QAbstractTableModel(parent),
|
||||
m_mode(mode),
|
||||
m_order(Qt::DescendingOrder)
|
||||
{
|
||||
m_nTotalSize = 0;
|
||||
m_alternateFlag = true;
|
||||
m_isDevGroupFilterEnable = false;
|
||||
//增加复归状态
|
||||
m_header <<tr("时间") << tr("优先级")
|
||||
<< tr("位置") << tr("责任区") << tr("告警类型") << tr("告警状态") << tr("复归状态") << tr("确认状态")
|
||||
<< tr(" 告警内容");
|
||||
LOGDEBUG("构造模型 start 模型:%d",int(mode));
|
||||
if(E_Alarm_Dock == m_mode)
|
||||
{
|
||||
connect(CAlarmDataCollect::instance(), SIGNAL(sigMsgConfirm()), this, SLOT(slotMsgConfirm()), Qt::QueuedConnection);
|
||||
m_sortKey= E_SORT_PRIORITY;
|
||||
}else
|
||||
{
|
||||
m_sortKey = E_SORT_TIME;
|
||||
}
|
||||
initialize();
|
||||
setDeviceGroupFilterEnable(false);
|
||||
removeDeviceGroupFilter();
|
||||
|
||||
connect(CAlarmDataCollect::instance(), SIGNAL(sigMsgRefresh()), this, SLOT(slotMsgRefresh()), Qt::QueuedConnection);
|
||||
connect(CAlarmMsgManage::instance(), SIGNAL(sigMsgArrived(QList<AlarmMsgPtr>)), this, SLOT(slotMsgArrived(QList<AlarmMsgPtr>)), Qt::QueuedConnection);
|
||||
connect(CAlarmDataCollect::instance(), SIGNAL(sigAlarmStateChanged(int, int)), this, SLOT(slotAlarmStateChanged(int, int)), Qt::QueuedConnection);
|
||||
|
||||
connect(CAlarmDataCollect::instance(),&CAlarmDataCollect::sigMsgRemove,this,&CAlarmItemModel::slotMsgRemove,Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
CAlarmItemModel::~CAlarmItemModel()
|
||||
{
|
||||
m_listShowAlarmInfo.clear();
|
||||
}
|
||||
|
||||
//登录或者注销或重新初始化model,或调用该初始化函数,会清空设备组过滤信息
|
||||
void CAlarmItemModel::initialize()
|
||||
{
|
||||
m_listHorAlignmentFlags.clear();
|
||||
for (int nIndex(0); nIndex < m_header.size(); nIndex++)
|
||||
{
|
||||
m_listHorAlignmentFlags.append(Qt::AlignHCenter);
|
||||
}
|
||||
initFilter();
|
||||
|
||||
slotMsgRefresh();
|
||||
}
|
||||
//设备组过滤使能;设备组过滤不显示系统信息
|
||||
void CAlarmItemModel::setDeviceGroupFilterEnable(bool bEnalbe)
|
||||
{
|
||||
m_isDevGroupFilterEnable = bEnalbe ;
|
||||
}
|
||||
|
||||
void CAlarmItemModel::initFilter()
|
||||
{
|
||||
m_isLevelFilterEnable = false;
|
||||
m_isLocationFilterEnable = false;
|
||||
m_isRegionFilterEnable = false;
|
||||
m_isStatusFilterEnable = false;
|
||||
m_isDeviceTypeFileter = false;
|
||||
m_isKeywordEnable = false;
|
||||
m_timeFilterEnable = false;
|
||||
m_confirmFilterEnable = false;
|
||||
m_returnFilterEnable = false;
|
||||
//if(m_mode != E_Alarm_Pop)
|
||||
//{
|
||||
// removeDeviceGroupFilter();
|
||||
//}
|
||||
}
|
||||
|
||||
E_Alarm_Mode CAlarmItemModel::getAlarmMode() const
|
||||
{
|
||||
return m_mode;
|
||||
}
|
||||
|
||||
int CAlarmItemModel::getShowAlarmCount() const
|
||||
{
|
||||
return m_listShowAlarmInfo.size();
|
||||
}
|
||||
|
||||
AlarmMsgPtr CAlarmItemModel::getAlarmInfo(const QModelIndex &index)
|
||||
{
|
||||
if(index.row() < m_listShowAlarmInfo.size())
|
||||
{
|
||||
return m_listShowAlarmInfo.at(index.row());
|
||||
}
|
||||
return AlarmMsgPtr(Q_NULLPTR);
|
||||
}
|
||||
|
||||
const QList<AlarmMsgPtr> CAlarmItemModel::getListShowAlarmInfo() const
|
||||
{
|
||||
return m_listShowAlarmInfo;
|
||||
}
|
||||
|
||||
void CAlarmItemModel::setColumnAlign(const int &column, const int &alignFlag)
|
||||
{
|
||||
Qt::AlignmentFlag flag = Qt::AlignHCenter;
|
||||
if(Qt::AlignLeft == (Qt::AlignmentFlag)alignFlag || Qt::AlignRight == (Qt::AlignmentFlag)alignFlag)
|
||||
{
|
||||
flag = (Qt::AlignmentFlag)alignFlag;
|
||||
}
|
||||
m_listHorAlignmentFlags.replace(column, flag);
|
||||
}
|
||||
|
||||
void CAlarmItemModel::insertAlarmMsg(const QList<AlarmMsgPtr> &infoList)
|
||||
{
|
||||
if(infoList.size() > 1000 || E_Alarm_Dock == m_mode)
|
||||
{
|
||||
beginResetModel();
|
||||
QList<AlarmMsgPtr>::const_iterator itpos = infoList.begin();
|
||||
while(itpos != infoList.end())
|
||||
{
|
||||
int left = calcLeft(*itpos);
|
||||
m_listShowAlarmInfo.insert(left, *itpos);
|
||||
itpos++;
|
||||
}
|
||||
endResetModel();
|
||||
}else
|
||||
{
|
||||
QList<AlarmMsgPtr>::const_iterator itpos = infoList.begin();
|
||||
while(itpos != infoList.end())
|
||||
{
|
||||
int left = calcLeft(*itpos);
|
||||
beginInsertRows(QModelIndex(), left, left);
|
||||
m_listShowAlarmInfo.insert(left, *itpos);
|
||||
endInsertRows();
|
||||
itpos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CAlarmItemModel::calcLeft(const AlarmMsgPtr &info)
|
||||
{
|
||||
int mid = -1;
|
||||
int left = 0;
|
||||
int right = m_listShowAlarmInfo.size() - 1;
|
||||
while(left <= right)
|
||||
{
|
||||
mid = (left + right) / 2;
|
||||
if (Qt::AscendingOrder == m_order)
|
||||
{
|
||||
if(info->lessThan(m_listShowAlarmInfo[mid], m_sortKey))
|
||||
{
|
||||
right = mid - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
left = mid + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_listShowAlarmInfo[mid]->lessThan(info, m_sortKey))
|
||||
{
|
||||
right = mid - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
left = mid + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return left;
|
||||
}
|
||||
|
||||
bool CAlarmItemModel::alternate() const
|
||||
{
|
||||
return m_alternateFlag;
|
||||
}
|
||||
|
||||
int CAlarmItemModel::filterCount()
|
||||
{
|
||||
if (0 == m_nTotalSize)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int nCount = m_nTotalSize - m_listShowAlarmInfo.size();
|
||||
if( nCount< 0)
|
||||
{
|
||||
return 0;
|
||||
}else
|
||||
{
|
||||
return nCount;
|
||||
}
|
||||
}
|
||||
|
||||
QVariant CAlarmItemModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if(Qt::DisplayRole == role && Qt::Horizontal == orientation)
|
||||
{
|
||||
return QVariant(m_header.at(section));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant CAlarmItemModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if(!index.isValid() || index.row() >= m_listShowAlarmInfo.count())
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if(Qt::TextAlignmentRole == role)
|
||||
{
|
||||
if(index.column() == (int)CONTENT)
|
||||
{
|
||||
return QVariant(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
}else
|
||||
{
|
||||
return QVariant(m_listHorAlignmentFlags.at(index.column()) | Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
}
|
||||
else if(Qt::DisplayRole == role)
|
||||
{
|
||||
switch ( index.column() )
|
||||
{
|
||||
case TIME :
|
||||
{
|
||||
return QDateTime::fromMSecsSinceEpoch(m_listShowAlarmInfo.at(index.row())->time_stamp).toString("yyyy-MM-dd hh:mm:ss.zzz");
|
||||
}
|
||||
case PRIORITY :
|
||||
{
|
||||
return CAlarmBaseData::instance()->queryPriorityDesc(m_listShowAlarmInfo.at(index.row())->priority);
|
||||
}
|
||||
case LOCATION :
|
||||
{
|
||||
return CAlarmBaseData::instance()->queryLocationDesc(m_listShowAlarmInfo.at(index.row())->location_id);
|
||||
}
|
||||
case REGION :
|
||||
{
|
||||
return CAlarmBaseData::instance()->queryRegionDesc(m_listShowAlarmInfo.at(index.row())->region_id);
|
||||
}
|
||||
case TYPE :
|
||||
{
|
||||
return CAlarmBaseData::instance()->queryAlarmTypeDesc(m_listShowAlarmInfo.at(index.row())->alm_type);
|
||||
}
|
||||
case STATUS :
|
||||
{
|
||||
return CAlarmBaseData::instance()->queryAlarmStatusDesc(m_listShowAlarmInfo.at(index.row())->alm_status);
|
||||
}
|
||||
case RETURNSTATUS:
|
||||
{
|
||||
if(E_ALS_ALARM == m_listShowAlarmInfo.at(index.row())->logic_state || E_ALS_ALARM_CFM == m_listShowAlarmInfo.at(index.row())->logic_state ||
|
||||
E_ALS_ALARM_DEL == m_listShowAlarmInfo.at(index.row())->logic_state || E_ALS_ALARM_CFM_DEL == m_listShowAlarmInfo.at(index.row())->logic_state) //未复归
|
||||
{
|
||||
return tr("未复归");
|
||||
}
|
||||
else if(E_ALS_RETURN == m_listShowAlarmInfo.at(index.row())->logic_state || E_ALS_RETURN_CFM == m_listShowAlarmInfo.at(index.row())->logic_state ||
|
||||
E_ALS_RETURN_DEL == m_listShowAlarmInfo.at(index.row())->logic_state || E_ALS_RETURN_CFM_DEL == m_listShowAlarmInfo.at(index.row())->logic_state)
|
||||
{
|
||||
return tr("已复归");
|
||||
}else
|
||||
{
|
||||
return tr("-");
|
||||
}
|
||||
}
|
||||
case CONFIRM :
|
||||
{
|
||||
if(E_ALS_ALARM == m_listShowAlarmInfo.at(index.row())->logic_state || E_ALS_RETURN == m_listShowAlarmInfo.at(index.row())->logic_state ||
|
||||
E_ALS_ALARM_DEL == m_listShowAlarmInfo.at(index.row())->logic_state || E_ALS_RETURN_DEL == m_listShowAlarmInfo.at(index.row())->logic_state) //< 未确认
|
||||
{
|
||||
return tr("未确认");
|
||||
}
|
||||
else if(E_ALS_ALARM_CFM == m_listShowAlarmInfo.at(index.row())->logic_state || E_ALS_RETURN_CFM == m_listShowAlarmInfo.at(index.row())->logic_state ||
|
||||
E_ALS_ALARM_CFM_DEL == m_listShowAlarmInfo.at(index.row())->logic_state || E_ALS_RETURN_CFM_DEL == m_listShowAlarmInfo.at(index.row())->logic_state ||
|
||||
ALS_EVT_ONLY == m_listShowAlarmInfo.at(index.row())->logic_state) //< 已确认
|
||||
{
|
||||
return tr("已确认");
|
||||
}
|
||||
}
|
||||
case CONTENT :
|
||||
{
|
||||
return m_listShowAlarmInfo.at(index.row())->content;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else if(Qt::ToolTipRole == role)
|
||||
{
|
||||
if(index.column() == (int)CONTENT && !QToolTip::isVisible())
|
||||
{
|
||||
QString tip = m_listShowAlarmInfo.at(index.row())->content;
|
||||
|
||||
return tip;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int CAlarmItemModel::columnCount(const QModelIndex &index) const
|
||||
{
|
||||
if (index.isValid())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m_header.count();
|
||||
}
|
||||
|
||||
int CAlarmItemModel::rowCount(const QModelIndex &index) const
|
||||
{
|
||||
if (index.isValid())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(E_Alarm_Dock == m_mode)
|
||||
{
|
||||
return DOCK_ROW_COUNT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_listShowAlarmInfo.count();
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ItemFlags CAlarmItemModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
{
|
||||
return Qt::NoItemFlags;
|
||||
}
|
||||
|
||||
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||
}
|
||||
|
||||
void CAlarmItemModel::sortColumn(int column, Qt::SortOrder order)
|
||||
{
|
||||
if(order == Qt::AscendingOrder)
|
||||
{
|
||||
m_order = Qt::AscendingOrder;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_order = Qt::DescendingOrder;
|
||||
}
|
||||
m_sortKey = (E_ALARM_SORTKEY)column;
|
||||
beginResetModel();
|
||||
sort();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
//<归并排序
|
||||
void CAlarmItemModel::sort()
|
||||
{
|
||||
QMap<int, PAIRLISTALARMINFO> mapAlarmInfo;
|
||||
//<分
|
||||
for(int nIndex(0); nIndex < m_listShowAlarmInfo.count(); nIndex++)
|
||||
{
|
||||
AlarmMsgPtr temp = m_listShowAlarmInfo.at(nIndex);
|
||||
mapAlarmInfo[nIndex / 1000].second.append(temp);
|
||||
}
|
||||
|
||||
//<快速排序
|
||||
for(int nMapIndex(0); nMapIndex < mapAlarmInfo.count(); nMapIndex++)
|
||||
{
|
||||
qucikSort(mapAlarmInfo[nMapIndex].second, 0, mapAlarmInfo[nMapIndex].second.count() - 1);
|
||||
}
|
||||
|
||||
PAIRLISTALARMINFO tempListAlarmInfo = mapAlarmInfo[0];
|
||||
for(int nPairIndex(1); nPairIndex < mapAlarmInfo.count(); nPairIndex++)
|
||||
{
|
||||
//<归并
|
||||
tempListAlarmInfo.first = 0;
|
||||
mapAlarmInfo[nPairIndex].first = 0;
|
||||
while(mapAlarmInfo[nPairIndex].first < mapAlarmInfo[nPairIndex].second.count())
|
||||
{
|
||||
if(tempListAlarmInfo.first >= tempListAlarmInfo.second.count())
|
||||
{
|
||||
tempListAlarmInfo.second.append(mapAlarmInfo[nPairIndex].second.at(mapAlarmInfo[nPairIndex].first));
|
||||
mapAlarmInfo[nPairIndex].first += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Qt::AscendingOrder == m_order)
|
||||
{
|
||||
if(!tempListAlarmInfo.second[tempListAlarmInfo.first]->lessThan(mapAlarmInfo[nPairIndex].second.at(mapAlarmInfo[nPairIndex].first), m_sortKey))
|
||||
{
|
||||
tempListAlarmInfo.second.insert(tempListAlarmInfo.first, mapAlarmInfo[nPairIndex].second.at(mapAlarmInfo[nPairIndex].first));
|
||||
mapAlarmInfo[nPairIndex].first += 1;
|
||||
}
|
||||
}
|
||||
else if(Qt::DescendingOrder == m_order)
|
||||
{
|
||||
if(!tempListAlarmInfo.second[tempListAlarmInfo.first]->moreThan(mapAlarmInfo[nPairIndex].second.at(mapAlarmInfo[nPairIndex].first), m_sortKey))
|
||||
{
|
||||
tempListAlarmInfo.second.insert(tempListAlarmInfo.first, mapAlarmInfo[nPairIndex].second.at(mapAlarmInfo[nPairIndex].first));
|
||||
mapAlarmInfo[nPairIndex].first += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
tempListAlarmInfo.first += 1;
|
||||
}
|
||||
}
|
||||
m_listShowAlarmInfo = tempListAlarmInfo.second;
|
||||
}
|
||||
|
||||
|
||||
void CAlarmItemModel::qucikSort(QList<AlarmMsgPtr> &list, int start, int last)
|
||||
{
|
||||
int index;
|
||||
while(start < last)
|
||||
{
|
||||
if(Qt::AscendingOrder == m_order)
|
||||
{
|
||||
index = partitionAscendingOrder(list, start, last);
|
||||
}
|
||||
else if(Qt::DescendingOrder == m_order)
|
||||
{
|
||||
index = partitionDescendingOrder(list, start, last);
|
||||
}
|
||||
qucikSort(list, start, index - 1);
|
||||
start=index+1; //<尾优化
|
||||
}
|
||||
}
|
||||
|
||||
int CAlarmItemModel::partitionAscendingOrder(QList<AlarmMsgPtr> &list, int start, int last)
|
||||
{
|
||||
AlarmMsgPtr info = list[start];
|
||||
int left = start;
|
||||
int right = last;
|
||||
while(left < right)
|
||||
{
|
||||
while(left < right && !list[right]->lessThan(info, m_sortKey))
|
||||
{
|
||||
--right;
|
||||
}
|
||||
list[left] = list[right];
|
||||
|
||||
while(left<right && list[left]->lessThan(info, m_sortKey))
|
||||
{
|
||||
++left;
|
||||
}
|
||||
list[right] = list[left];
|
||||
}
|
||||
list[left] = info;
|
||||
return left;
|
||||
}
|
||||
|
||||
int CAlarmItemModel::partitionDescendingOrder(QList<AlarmMsgPtr> &list, int start, int last)
|
||||
{
|
||||
AlarmMsgPtr info = list[start];
|
||||
int left = start;
|
||||
int right = last;
|
||||
while(left < right)
|
||||
{
|
||||
while(left < right && !list[right]->moreThan(info, m_sortKey))
|
||||
{
|
||||
--right;
|
||||
}
|
||||
list[left] = list[right];
|
||||
|
||||
while(left<right && list[left]->moreThan(info, m_sortKey))
|
||||
{
|
||||
++left;
|
||||
}
|
||||
list[right] = list[left];
|
||||
}
|
||||
list[left] = info;
|
||||
return left;
|
||||
}
|
||||
|
||||
void CAlarmItemModel::setPriorityFilter(bool &isCheck, QList<int> &priorityFilter)
|
||||
{
|
||||
m_isLevelFilterEnable = isCheck;
|
||||
m_levelFilter = priorityFilter;
|
||||
slotMsgRefresh();
|
||||
}
|
||||
|
||||
void CAlarmItemModel::setLocationFilter(bool &isCheck, QList<int> &locationFilter)
|
||||
{
|
||||
m_isLocationFilterEnable = isCheck;
|
||||
m_locationFilter = locationFilter;
|
||||
slotMsgRefresh();
|
||||
}
|
||||
|
||||
void CAlarmItemModel::setAlarmTypeFilter(bool &isCheck, QList<int> &alarmTypeFilter,bool &other)
|
||||
{
|
||||
m_isStatusFilterEnable = isCheck;
|
||||
m_statusFilter2 = alarmTypeFilter;
|
||||
m_statusFilter = alarmTypeFilter;
|
||||
if(other == true)
|
||||
{
|
||||
QMap<int, QString> otherStatusMap = CAlarmBaseData::instance()->getAlarmOtherStatus();
|
||||
QMap<int, QString>::iterator it = otherStatusMap.begin();
|
||||
for(;it != otherStatusMap.end(); ++it)
|
||||
{
|
||||
m_statusFilter.append(it.key());
|
||||
}
|
||||
}
|
||||
slotMsgRefresh();
|
||||
}
|
||||
|
||||
void CAlarmItemModel::setAlarmTimeFilter(bool &isCheck, QDate &startTime, QDate &endTime)
|
||||
{
|
||||
m_timeFilterEnable = isCheck;
|
||||
if(isCheck)
|
||||
{
|
||||
QTime time_1(0,0,0,0);
|
||||
QTime time_2(23,59,59);
|
||||
m_startTime.setDate(startTime);
|
||||
m_startTime.setTime(time_1);
|
||||
m_endTime.setDate(endTime);
|
||||
m_endTime.setTime(time_2);
|
||||
}
|
||||
slotMsgRefresh();
|
||||
}
|
||||
|
||||
void CAlarmItemModel::setAlarmTimeFilter(bool &isCheck)
|
||||
{
|
||||
m_timeFilterEnable = isCheck;
|
||||
slotMsgRefresh();
|
||||
}
|
||||
|
||||
void CAlarmItemModel::setFilter(const bool &isLevelFilterEnable, const QList<int> &levelFilter,
|
||||
const bool &isStationFilterEnable, const QList<int> &stationFilter,
|
||||
const bool &isRegionFilterEnable, const QList<int> ®ionFilter,
|
||||
const bool &isStatusFilterEnable, const QList<int> &statusFilter,
|
||||
const bool &isDeviceTypeFilter, const QString &subSystem, const QString &deviceType,
|
||||
const bool &isKeywordFilterEnable, const QString &keyword,
|
||||
const bool &timeFilterEnable, const QDateTime &startTime, const QDateTime &endTime,
|
||||
const bool &confirmFilterEnable, const bool &isConfirm,
|
||||
const bool &returnFilterEnable, const bool &isReturn)
|
||||
{
|
||||
m_isLevelFilterEnable = isLevelFilterEnable;
|
||||
m_levelFilter = levelFilter;
|
||||
m_isLocationFilterEnable = isStationFilterEnable;
|
||||
m_locationFilter = stationFilter;
|
||||
m_isRegionFilterEnable = isRegionFilterEnable;
|
||||
m_regionFilter = regionFilter;
|
||||
m_isStatusFilterEnable = isStatusFilterEnable;
|
||||
m_statusFilter2 = statusFilter;
|
||||
m_statusFilter = statusFilter;
|
||||
if(statusFilter.contains(OTHERSTATUS))
|
||||
{
|
||||
QMap<int, QString> otherStatusMap = CAlarmBaseData::instance()->getAlarmOtherStatus();
|
||||
QMap<int, QString>::iterator it = otherStatusMap.begin();
|
||||
for(;it != otherStatusMap.end(); ++it)
|
||||
{
|
||||
m_statusFilter.append(it.key());
|
||||
}
|
||||
}
|
||||
m_isDeviceTypeFileter = isDeviceTypeFilter;
|
||||
m_subSystem = subSystem;
|
||||
m_deviceType = deviceType;
|
||||
m_isKeywordEnable = isKeywordFilterEnable;
|
||||
m_keyowrd = keyword;
|
||||
m_timeFilterEnable = timeFilterEnable;
|
||||
m_startTime = startTime;
|
||||
m_endTime = endTime;
|
||||
m_confirmFilterEnable = confirmFilterEnable;
|
||||
m_returnFilterEnable = returnFilterEnable;
|
||||
m_isConfirm = isConfirm;
|
||||
m_isReturn = isReturn;
|
||||
|
||||
slotMsgRefresh();
|
||||
}
|
||||
|
||||
void CAlarmItemModel::getFilter(bool &isLevelFilterEnable, QList<int> &levelFilter,
|
||||
bool &isLocationFilterEnable, QList<int> &locationFilter,
|
||||
bool &isRegionFilterEnable, QList<int> ®ionFilter,
|
||||
bool &isStatusFilterEnable, QList<int> &alarmStatusFilter,
|
||||
bool &deviceTypeFilter, QString &subSystem, QString &deviceType,
|
||||
bool &keywordFilterEnable, QString &keyword,
|
||||
bool &timeFilterEnable, QDateTime &startTime, QDateTime &endTime,
|
||||
bool &confirmFilterEnable, bool &isConfirm,
|
||||
bool &returnFilterEnable, bool &isReturn)
|
||||
{
|
||||
isLevelFilterEnable = m_isLevelFilterEnable;
|
||||
levelFilter = m_levelFilter;
|
||||
isLocationFilterEnable = m_isLocationFilterEnable;
|
||||
locationFilter = m_locationFilter;
|
||||
isRegionFilterEnable = m_isRegionFilterEnable;
|
||||
regionFilter = m_regionFilter;
|
||||
isStatusFilterEnable = m_isStatusFilterEnable;
|
||||
alarmStatusFilter = m_statusFilter2;
|
||||
subSystem = m_subSystem;
|
||||
deviceTypeFilter = m_isDeviceTypeFileter;
|
||||
deviceType = m_deviceType;
|
||||
keywordFilterEnable = m_isKeywordEnable;
|
||||
keyword = m_keyowrd;
|
||||
timeFilterEnable = m_timeFilterEnable;
|
||||
startTime = m_startTime;
|
||||
endTime = m_endTime;
|
||||
confirmFilterEnable = m_confirmFilterEnable;
|
||||
isConfirm = m_isConfirm;
|
||||
returnFilterEnable = m_returnFilterEnable;
|
||||
isReturn = m_isReturn;
|
||||
}
|
||||
|
||||
void CAlarmItemModel::addDeviceFilter(const QString &device)
|
||||
{
|
||||
m_deviceFilter.insert(device);
|
||||
//slotMsgRefresh();
|
||||
}
|
||||
|
||||
void CAlarmItemModel::removeDeviceFilter(const QString &device)
|
||||
{
|
||||
m_deviceFilter.remove(device);
|
||||
//slotMsgRefresh();
|
||||
}
|
||||
|
||||
void CAlarmItemModel::addPointTagFilter(const QList<QString> &pointList)
|
||||
{
|
||||
for(int i =0;i<pointList.size();i++)
|
||||
{
|
||||
m_pointFilter.insert(pointList.at(i));
|
||||
}
|
||||
//slotMsgRefresh();
|
||||
}
|
||||
|
||||
void CAlarmItemModel::addDeviceGroupFilter()
|
||||
{
|
||||
for(QString group : CAlarmBaseData::instance()->getDevGroupTagList())
|
||||
{
|
||||
m_deviceGroupFilter.insert(group);
|
||||
}
|
||||
slotMsgRefresh();
|
||||
}
|
||||
|
||||
void CAlarmItemModel::removeDeviceGroupFilter()
|
||||
{
|
||||
m_deviceGroupFilter.clear();
|
||||
}
|
||||
|
||||
void CAlarmItemModel::addDeviceGroupFilter(const QString &device)
|
||||
{
|
||||
QString deviceG = device;
|
||||
QStringList devGList = deviceG.split(",");
|
||||
foreach (QString devG, devGList) {
|
||||
m_deviceGroupFilter.insert(devG);
|
||||
}
|
||||
slotMsgRefresh();
|
||||
}
|
||||
|
||||
//device 需要过滤告警的设备
|
||||
void CAlarmItemModel::addDeviceGroupFilter2(const QString &device)
|
||||
{
|
||||
addDeviceGroupFilter(); //增加所有设备组
|
||||
QString deviceG = device;
|
||||
QStringList devGList = deviceG.split(",");
|
||||
foreach (QString devG, devGList)
|
||||
{
|
||||
m_deviceGroupFilter.remove(devG);
|
||||
}
|
||||
slotMsgRefresh();
|
||||
}
|
||||
|
||||
void CAlarmItemModel::removeDeviceGroupFilter(const QString &device)
|
||||
{
|
||||
m_deviceGroupFilter.remove(device); //删除显示
|
||||
slotMsgRefresh();
|
||||
}
|
||||
|
||||
bool CAlarmItemModel::conditionFilter(const AlarmMsgPtr &info)
|
||||
{
|
||||
//===========================错误优先级、车站、责任区、告警类型将显示==============================//
|
||||
//< 等级
|
||||
if(m_isLevelFilterEnable && !m_levelFilter.contains(info->priority))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//< 车站
|
||||
if(m_isLocationFilterEnable && !m_locationFilter.contains(info->location_id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//< 责任区
|
||||
if(m_isRegionFilterEnable && !m_regionFilter.contains(info->region_id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//< 类型
|
||||
if(m_isStatusFilterEnable && !m_statusFilter.contains(info->alm_status))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//< 设备类型
|
||||
if(m_isDeviceTypeFileter)
|
||||
{
|
||||
// QString qita = QString("其他");
|
||||
// ofstream of("d:\\type.txt",ios::app);
|
||||
// if(0 == strcmp(qita.toStdString().c_str(),m_deviceType.toStdString().c_str()))
|
||||
// {
|
||||
// if(CAlarmBaseData::instance()->queryDevTypeByDesc(m_deviceType) == info->dev_type
|
||||
// )
|
||||
// {
|
||||
|
||||
// }
|
||||
// }
|
||||
// else if(CAlarmBaseData::instance()->queryDevTypeByDesc(m_deviceType) != info->dev_type)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// of<<"其他:"<<CAlarmBaseData::instance()->queryDevTypeByDesc(qita)<<" "; //其他 5
|
||||
// qita = QString("配电柜");
|
||||
// of<<"配电柜"<<CAlarmBaseData::instance()->queryDevTypeByDesc(qita)<<" "; //配电柜 1
|
||||
// qita = QString("UPS");
|
||||
// of<<"UPS:"<<CAlarmBaseData::instance()->queryDevTypeByDesc(qita)<<" "; //UPS 2
|
||||
// qita = QString("BMS");
|
||||
// of<<"BMS:"<<CAlarmBaseData::instance()->queryDevTypeByDesc(qita)<<" "; //BMS 4
|
||||
// qita = QString("高频开关电源"); //高频 3
|
||||
// of<<"高频开关电源:"<<CAlarmBaseData::instance()->queryDevTypeByDesc(qita)<<" ";
|
||||
// of<<"m_deviceType:"<<m_deviceType.toStdString()<<" ";
|
||||
// of<<"当前:"<<info->dev_type<<" 内容:"<<info->content.toStdString()<<" alm_type:"<<info->alm_type<<endl<<endl<<endl;
|
||||
// of.close();
|
||||
if(CAlarmBaseData::instance()->queryDevTypeByDesc(m_deviceType) != info->dev_type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//< 点-设备或设备组
|
||||
/*
|
||||
if(E_Alarm_Pop == m_mode)
|
||||
{
|
||||
//点标签过滤
|
||||
if(info->device.isEmpty() || !m_deviceGroupFilter.contains(info->dev_group_tag))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
//<< //如果告警信息info包含在队列m_deviceGroupFilter中 ->返回FASLE,不显示
|
||||
//<< //m_deviceGroupFilter 不显示告警的设备组需要放入到队列中
|
||||
if(m_deviceGroupFilter.contains(info->dev_group_tag))
|
||||
{
|
||||
return false; //不显示
|
||||
}
|
||||
//LOGERROR("conditionFilter::m_isDevGroupFilterEnable=%d,m_deviceGroupFilter=%d",m_isDevGroupFilterEnable,m_deviceGroupFilter.size());//
|
||||
if((m_isDevGroupFilterEnable == true) && (info->alm_type == ALM_TYPE_SYSTEM) ) //设备组使能,不显示系统信息
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//< 关键字
|
||||
if(m_isKeywordEnable && !info->content.contains(m_keyowrd) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//< 时间
|
||||
if(m_timeFilterEnable)
|
||||
{
|
||||
if(m_startTime.toMSecsSinceEpoch() > (qint64)(info->time_stamp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(m_endTime.toMSecsSinceEpoch() < (qint64)(info->time_stamp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//< 是否已确认
|
||||
if(m_confirmFilterEnable)
|
||||
{
|
||||
if(m_isConfirm)
|
||||
{
|
||||
if(info->logic_state == E_ALS_ALARM || info->logic_state == E_ALS_RETURN)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(info->logic_state == E_ALS_ALARM_CFM || info->logic_state == E_ALS_RETURN_CFM)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(m_returnFilterEnable)
|
||||
{
|
||||
if(m_isReturn)
|
||||
{
|
||||
if(info->logic_state == E_ALS_ALARM || info->logic_state == E_ALS_ALARM_CFM || info->logic_state == ALS_EVT_ONLY)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(info->logic_state == E_ALS_RETURN || info->logic_state == E_ALS_RETURN_CFM || info->logic_state == ALS_EVT_ONLY)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CAlarmItemModel::updateAlternate()
|
||||
{
|
||||
m_alternateFlag = !m_alternateFlag;
|
||||
}
|
||||
|
||||
void CAlarmItemModel::slotMsgRefresh()
|
||||
{
|
||||
//ofstream of("d:\\msg.txt",ios::app);
|
||||
beginResetModel();
|
||||
m_listShowAlarmInfo.clear();
|
||||
QList<AlarmMsgPtr> listAlarmInfo = CAlarmMsgManage::instance()->getListAlarmInfo();
|
||||
foreach (AlarmMsgPtr info, listAlarmInfo)
|
||||
{
|
||||
if(conditionFilter(info))
|
||||
{
|
||||
m_listShowAlarmInfo.append(info);
|
||||
// of<<"type:"<<info.data()->alm_type<< " "<<
|
||||
// "app_id:"<<info.data()->app_id<< " "<<
|
||||
// "priority:"<<info.data()->priority<< " "<<
|
||||
// "content:"<<info.data()->content.toStdString()<< " "<<
|
||||
// "alm_status:"<<info.data()->alm_status<< " "<<
|
||||
// "dev_type:"<<info.data()->dev_type<< " "<<
|
||||
// "priorityOrder:"<<info.data()->priorityOrder<<endl;
|
||||
}
|
||||
}
|
||||
//of<<endl;
|
||||
//of.close();
|
||||
sort();
|
||||
endResetModel();
|
||||
slotMsgConfirm();
|
||||
}
|
||||
|
||||
void CAlarmItemModel::slotMsgArrived(QList<AlarmMsgPtr> listMsg)
|
||||
{
|
||||
//处理新告警消息
|
||||
QList<AlarmMsgPtr>::const_iterator it = listMsg.constBegin();
|
||||
QList<AlarmMsgPtr> addMsgList;
|
||||
while (it != listMsg.constEnd())
|
||||
{
|
||||
if(conditionFilter(*it))
|
||||
{
|
||||
addMsgList.append(*it);
|
||||
}
|
||||
++it;
|
||||
}
|
||||
insertAlarmMsg(addMsgList);
|
||||
}
|
||||
|
||||
void CAlarmItemModel::slotMsgConfirm()
|
||||
{
|
||||
if(E_Alarm_Dock == m_mode)
|
||||
{
|
||||
beginResetModel();
|
||||
for(int nIndex = m_listShowAlarmInfo.size() - 1; nIndex >= 0; --nIndex)
|
||||
{
|
||||
E_ALARM_LOGICSTATE state = m_listShowAlarmInfo.at(nIndex)->logic_state;
|
||||
if(state == E_ALS_ALARM_CFM || state == E_ALS_RETURN_CFM)
|
||||
{
|
||||
m_listShowAlarmInfo.removeAt(nIndex);
|
||||
}
|
||||
}
|
||||
endResetModel();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmItemModel::slotMsgRemove(int removeNum)
|
||||
{
|
||||
if(removeNum >1000 || E_Alarm_Dock == m_mode)
|
||||
{
|
||||
beginResetModel();
|
||||
for(int nIndex = m_listShowAlarmInfo.size() - 1; nIndex >= 0; --nIndex)
|
||||
{
|
||||
if(m_listShowAlarmInfo.at(nIndex)->deleteFlag)
|
||||
{
|
||||
m_listShowAlarmInfo.removeAt(nIndex);
|
||||
}
|
||||
}
|
||||
endResetModel();
|
||||
}else
|
||||
{
|
||||
for(int nIndex = m_listShowAlarmInfo.size() - 1; nIndex >= 0; --nIndex)
|
||||
{
|
||||
if(m_listShowAlarmInfo.at(nIndex)->deleteFlag)
|
||||
{
|
||||
beginRemoveRows(QModelIndex(), nIndex, nIndex);
|
||||
m_listShowAlarmInfo.removeAt(nIndex);
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmItemModel::slotAlarmStateChanged(int total, int unConfirm)
|
||||
{
|
||||
Q_UNUSED(unConfirm)
|
||||
m_nTotalSize = total;
|
||||
}
|
||||
197
product/src/gui/plugin/AlarmWidget_pad/CAlarmItemModel.h
Normal file
197
product/src/gui/plugin/AlarmWidget_pad/CAlarmItemModel.h
Normal file
@ -0,0 +1,197 @@
|
||||
#ifndef CALARMITEMMODEL_H
|
||||
#define CALARMITEMMODEL_H
|
||||
|
||||
#include <QSet>
|
||||
#include <QMutex>
|
||||
#include <QDateTime>
|
||||
#include <QAbstractTableModel>
|
||||
#include "CAlarmMsgInfo.h"
|
||||
#include "CAlarmCommon.h"
|
||||
extern const int DOCK_ROW_COUNT;
|
||||
extern const int MAX_ROW_COUNT;
|
||||
|
||||
|
||||
|
||||
class CAlarmView;
|
||||
class CAlarmMsgInfo;
|
||||
|
||||
class CAlarmItemModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
enum ColumnField
|
||||
{
|
||||
TIME = 0,
|
||||
PRIORITY,
|
||||
LOCATION,
|
||||
REGION,
|
||||
TYPE,
|
||||
STATUS,
|
||||
RETURNSTATUS,
|
||||
CONFIRM,
|
||||
CONTENT
|
||||
};
|
||||
|
||||
CAlarmItemModel(E_Alarm_Mode mode, QObject *parent = Q_NULLPTR);
|
||||
~CAlarmItemModel();
|
||||
|
||||
void initialize();
|
||||
|
||||
void initFilter();
|
||||
|
||||
E_Alarm_Mode getAlarmMode() const;
|
||||
|
||||
int getShowAlarmCount() const;
|
||||
|
||||
AlarmMsgPtr getAlarmInfo(const QModelIndex &index);
|
||||
|
||||
const QList<AlarmMsgPtr> getListShowAlarmInfo() const;
|
||||
|
||||
|
||||
void setColumnAlign(const int &column, const int &alignFlag);
|
||||
|
||||
/**
|
||||
* @brief insertAlarmMsg 数采通知模型告警到达
|
||||
* @param info
|
||||
*/
|
||||
void insertAlarmMsg(const QList<AlarmMsgPtr> & infoList);
|
||||
|
||||
int calcLeft(const AlarmMsgPtr &info);
|
||||
/**
|
||||
* @brief alternate 闪烁状态切换
|
||||
* @return
|
||||
*/
|
||||
bool alternate() const;
|
||||
|
||||
int filterCount();
|
||||
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
virtual int columnCount(const QModelIndex &index = QModelIndex()) const;
|
||||
virtual int rowCount(const QModelIndex &index = QModelIndex()) const;
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
void sort();
|
||||
void qucikSort(QList<AlarmMsgPtr> &listAlarmInfo, int left, int right);
|
||||
int partitionAscendingOrder(QList<AlarmMsgPtr> &list, int start, int last);
|
||||
int partitionDescendingOrder(QList<AlarmMsgPtr> &list, int start, int last);
|
||||
|
||||
void setPriorityFilter(bool &isCheck, QList<int> &priorityFilter);
|
||||
void setLocationFilter(bool &isCheck, QList<int> &locationFilter);
|
||||
void setAlarmTypeFilter(bool &isCheck, QList<int> &alarmTypeFilter, bool &other);
|
||||
void setAlarmTimeFilter(bool &isCheck, QDate &startTime,QDate &endTime);
|
||||
void setAlarmTimeFilter(bool &isCheck);
|
||||
/**
|
||||
* 设置模型数据过滤条件,过滤显示数据
|
||||
*/
|
||||
void setFilter(const bool &isLevelFilterEnable, const QList<int> &levelFilter,
|
||||
const bool &isStationFilterEnable, const QList<int> &stationFilter,
|
||||
const bool &isRegionFilterEnable, const QList<int> ®ionFilter,
|
||||
const bool &isStatusFilterEnable, const QList<int> &statusFilter,
|
||||
const bool &isDeviceTypeFilter = false, const QString &subSystem = QString(), const QString &deviceType = QString(),
|
||||
const bool &isKeywordFilterEnable = false, const QString &keyword = QString(),
|
||||
const bool &timeFilterEnable = false, const QDateTime &startTime = QDateTime(),
|
||||
const QDateTime &endTime = QDateTime(), const bool &confirmFilterEnable = false, const bool &isConfirm = false,const bool &returnFilterEnable = false, const bool &isReturn= false);
|
||||
|
||||
/**
|
||||
* 获取模型数据过滤条件,用于初始化过滤对话框
|
||||
*/
|
||||
void getFilter(bool &isLevelFilterEnable, QList<int> &levelFilter,
|
||||
bool &isLocationFilterEnable, QList<int> &locationFilter,
|
||||
bool &isRegionFilterEnable, QList<int> ®ionFilter,
|
||||
bool &isStatusFilterEnable, QList<int> &alarmStatusFilter,
|
||||
bool &deviceTypeFilter, QString &subSystem, QString &deviceType,
|
||||
bool &keywordFilterEnable, QString &keyword,
|
||||
bool &timeFilterEnable, QDateTime &startTime, QDateTime &endTime,
|
||||
bool &confirmFilterEnable, bool &isConfirm,
|
||||
bool &returnFilterEnable, bool &isReturn);
|
||||
|
||||
|
||||
void addDeviceFilter(const QString &device);
|
||||
void removeDeviceFilter(const QString &device);
|
||||
|
||||
void addPointTagFilter(const QList<QString> &pointList);
|
||||
|
||||
void setDeviceGroupFilterEnable(bool bEnalbe) ; //设备组过滤使能;设备组过滤不显示系统信息
|
||||
void addDeviceGroupFilter();
|
||||
void removeDeviceGroupFilter();
|
||||
void addDeviceGroupFilter(const QString &device);
|
||||
void addDeviceGroupFilter2(const QString &device);
|
||||
|
||||
void removeDeviceGroupFilter(const QString &device);
|
||||
|
||||
bool conditionFilter(const AlarmMsgPtr &info);
|
||||
|
||||
void updateAlternate();
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
void sortColumn(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
||||
|
||||
/**
|
||||
* @brief slotMsgRefresh 更新model,重新拉取数据
|
||||
*/
|
||||
void slotMsgRefresh();
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief slotMsgArrived 告警消息到达
|
||||
* @param info
|
||||
*/
|
||||
void slotMsgArrived(QList<AlarmMsgPtr> listMsg);
|
||||
|
||||
/**
|
||||
* @brief slotMsgConfirm 告警消息确认
|
||||
*/
|
||||
void slotMsgConfirm();
|
||||
|
||||
/**
|
||||
* @brief slotMsgArrived 告警消息删除
|
||||
*/
|
||||
void slotMsgRemove(int removeNum);
|
||||
|
||||
void slotAlarmStateChanged(int total, int unConfirm);
|
||||
|
||||
private:
|
||||
E_Alarm_Mode m_mode;
|
||||
QStringList m_header;
|
||||
QList<AlarmMsgPtr> m_listShowAlarmInfo;
|
||||
bool m_alternateFlag; //闪烁颜色切换
|
||||
E_ALARM_SORTKEY m_sortKey; //排序规则
|
||||
Qt::SortOrder m_order;
|
||||
|
||||
int m_nTotalSize;
|
||||
|
||||
QList<Qt::AlignmentFlag> m_listHorAlignmentFlags; //< 水平对齐方式
|
||||
|
||||
//< Filter
|
||||
bool m_isLevelFilterEnable; //是否按告警级别过滤
|
||||
QList<int> m_levelFilter; //告警级别过滤
|
||||
bool m_isLocationFilterEnable; //是否按车站过滤
|
||||
QList<int> m_locationFilter; //车站过滤
|
||||
bool m_isRegionFilterEnable; //是否按责任区过滤
|
||||
QList<int> m_regionFilter; //责任区过滤
|
||||
bool m_isStatusFilterEnable; //是否按告警类型过滤
|
||||
QList<int> m_statusFilter; //告警类型过滤(所有的要过滤告警状态--如果其他状态没有被勾选,则与下面的内容相同)
|
||||
QList<int> m_statusFilter2; //告警类型过滤(显示在过滤窗中的告警状态)
|
||||
bool m_isDeviceTypeFileter; //设备类型过滤
|
||||
QString m_subSystem; //子系统
|
||||
QString m_deviceType; //设备类型
|
||||
bool m_isKeywordEnable; //关键字过滤
|
||||
QString m_keyowrd; //关键字
|
||||
bool m_timeFilterEnable; //是否根据时间过滤
|
||||
QDateTime m_startTime; //起始时间
|
||||
QDateTime m_endTime; //终止时间
|
||||
bool m_confirmFilterEnable; //是否根据状态确认过滤
|
||||
bool m_isConfirm; //状态是否确认
|
||||
bool m_returnFilterEnable; //是否根据复归状态过滤
|
||||
bool m_isReturn; //是否已复归
|
||||
QSet<QString> m_deviceFilter; //< 设备过滤
|
||||
QSet<QString> m_pointFilter; //标签过滤
|
||||
bool m_isDevGroupFilterEnable ; //设备组过滤使能
|
||||
QSet<QString> m_deviceGroupFilter; //<设备组过滤
|
||||
};
|
||||
|
||||
#endif // ALARMITEMMODEL_H
|
||||
592
product/src/gui/plugin/AlarmWidget_pad/CAlarmMediaPlayer.cpp
Normal file
592
product/src/gui/plugin/AlarmWidget_pad/CAlarmMediaPlayer.cpp
Normal file
@ -0,0 +1,592 @@
|
||||
|
||||
#ifdef OS_WINDOWS
|
||||
//< 为了检测可用声卡
|
||||
#include <mmdeviceapi.h>
|
||||
#include <endpointvolume.h>
|
||||
#endif
|
||||
|
||||
#include <QDir>
|
||||
#include <QDateTime>
|
||||
#include <QAudioDeviceInfo>
|
||||
#include <QMediaPlaylist>
|
||||
#include "CAlarmMediaPlayer.h"
|
||||
#include "pub_utility_api/FileUtil.h"
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include "pub_utility_api/I18N.h"
|
||||
#include "CAlarmSetMng.h"
|
||||
#include "service/alarm_server_api/AlarmCommonDef.h"
|
||||
#include "CAlarmMsgManage.h"
|
||||
|
||||
using namespace iot_public;
|
||||
CAlarmMediaPlayer * CAlarmMediaPlayer::m_pInstance = NULL;
|
||||
CAlarmMediaPlayer *CAlarmMediaPlayer::instance()
|
||||
{
|
||||
if(NULL == m_pInstance)
|
||||
{
|
||||
m_pInstance = new CAlarmMediaPlayer();
|
||||
}
|
||||
return m_pInstance;
|
||||
}
|
||||
|
||||
CAlarmMediaPlayer::CAlarmMediaPlayer()
|
||||
:m_bHaveValidAudioDev(true),m_pMediaPlayer(Q_NULLPTR),m_pTextToSpeech(Q_NULLPTR),m_pTimerCheckAudioDev(Q_NULLPTR),m_voice(100)
|
||||
{
|
||||
m_readFlag = true;
|
||||
QDir dir(QString::fromStdString(iot_public::CFileUtil::getCurModuleDir()));
|
||||
dir.cdUp();
|
||||
dir.cdUp();
|
||||
dir.cd("data");
|
||||
dir.cd("sound");
|
||||
initSetCfg();
|
||||
m_strMediaPath = dir.absolutePath() + QDir::separator();
|
||||
m_bChange = true;
|
||||
m_pTimerCheckAudioDev = new QTimer();
|
||||
m_pTimerCheckAudioDev->setInterval(5000);
|
||||
connect(m_pTimerCheckAudioDev, SIGNAL(timeout()), this, SLOT(checkAudioDev()),Qt::QueuedConnection);
|
||||
m_pTimerCheckAudioStatus = new QTimer();
|
||||
m_pTimerCheckAudioStatus->setInterval(30000);
|
||||
connect(m_pTimerCheckAudioStatus,&QTimer::timeout, this, &CAlarmMediaPlayer::checkAudioStatus,Qt::QueuedConnection);
|
||||
checkAudioDev();
|
||||
checkAudioStatus();
|
||||
m_pTimerCheckAudioDev->start();
|
||||
m_pTimerCheckAudioStatus->start();
|
||||
|
||||
//< 需在checkAudioDev()之后调用
|
||||
|
||||
if(m_act == (int)E_ALARM_SOUND)
|
||||
{
|
||||
initPlayer();
|
||||
}else
|
||||
{
|
||||
initSpeech();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::updateAudioCues()
|
||||
{
|
||||
if(m_act == (int)E_ALARM_SOUND)
|
||||
{
|
||||
updateAudioCuesPlayer();
|
||||
}else
|
||||
{
|
||||
updateAudioCuesSpeech();
|
||||
}
|
||||
}
|
||||
|
||||
CAlarmMediaPlayer::~CAlarmMediaPlayer()
|
||||
{
|
||||
if(Q_NULLPTR != m_pTimerCheckAudioDev)
|
||||
{
|
||||
m_pTimerCheckAudioDev->stop();
|
||||
m_pTimerCheckAudioDev->deleteLater();
|
||||
}
|
||||
m_pTimerCheckAudioDev = NULL;
|
||||
if(Q_NULLPTR != m_pTimerCheckAudioStatus)
|
||||
{
|
||||
m_pTimerCheckAudioStatus->stop();
|
||||
m_pTimerCheckAudioStatus->deleteLater();
|
||||
}
|
||||
m_pTimerCheckAudioStatus = NULL;
|
||||
if(Q_NULLPTR != m_pMediaPlayer)
|
||||
{
|
||||
if(QMediaPlayer::StoppedState != m_pMediaPlayer->state())
|
||||
{
|
||||
m_pMediaPlayer->disconnect();
|
||||
m_pMediaPlayer->stop();
|
||||
}
|
||||
delete m_pMediaPlayer;
|
||||
}
|
||||
m_pMediaPlayer = Q_NULLPTR;
|
||||
|
||||
if(Q_NULLPTR != m_pTextToSpeech)
|
||||
{
|
||||
if(QTextToSpeech::Ready != m_pTextToSpeech->state())
|
||||
{
|
||||
m_pTextToSpeech->disconnect();
|
||||
m_pTextToSpeech->stop();
|
||||
}
|
||||
delete m_pTextToSpeech;
|
||||
}
|
||||
m_pTextToSpeech = Q_NULLPTR;
|
||||
delete m_pInstance;
|
||||
m_pInstance = Q_NULLPTR;
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::initPlayer()
|
||||
{
|
||||
if(Q_NULLPTR != m_pMediaPlayer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_pMediaPlayer = new QMediaPlayer();
|
||||
m_pMediaPlayer->setVolume(m_voice);
|
||||
connect(m_pMediaPlayer, &QMediaPlayer::stateChanged, this, &CAlarmMediaPlayer::playerStateChanged,Qt::QueuedConnection);
|
||||
connect(m_pMediaPlayer, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(printError(QMediaPlayer::Error)),Qt::QueuedConnection);
|
||||
|
||||
QMediaPlaylist *pPlayList = new QMediaPlaylist(this);
|
||||
pPlayList->setPlaybackMode(QMediaPlaylist::Sequential);
|
||||
pPlayList->clear();
|
||||
m_pMediaPlayer->setPlaylist(pPlayList);
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::initSpeech()
|
||||
{
|
||||
if(Q_NULLPTR != m_pTextToSpeech)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList engineList = QTextToSpeech::availableEngines();
|
||||
|
||||
if(engineList.isEmpty())
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if(m_engine.isEmpty() || !engineList.contains(m_engine))
|
||||
{
|
||||
#ifdef OS_LINUX
|
||||
m_pTextToSpeech = Q_NULLPTR;
|
||||
return;
|
||||
#else
|
||||
m_pTextToSpeech = new QTextToSpeech(this);
|
||||
#endif
|
||||
}else
|
||||
{
|
||||
m_pTextToSpeech = new QTextToSpeech(m_engine,this);
|
||||
}
|
||||
m_pTextToSpeech->setVolume(m_voice);
|
||||
connect(m_pTextToSpeech, &QTextToSpeech::stateChanged, this, &CAlarmMediaPlayer::speechStateChanged,Qt::QueuedConnection);
|
||||
QVector<QLocale> locales = m_pTextToSpeech->availableLocales();
|
||||
if(!m_language.isEmpty())
|
||||
{
|
||||
foreach (const QLocale &locale, locales) {
|
||||
if (locale.name() == m_language)
|
||||
{
|
||||
m_pTextToSpeech->setLocale(locale);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
QVector<QVoice> voices = m_pTextToSpeech->availableVoices();
|
||||
if(!m_voiceName.isEmpty())
|
||||
{
|
||||
foreach (const QVoice &voice, voices) {
|
||||
if (voice.name() == m_voiceName)
|
||||
{
|
||||
m_pTextToSpeech->setVoice(voice);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::initSetCfg()
|
||||
{
|
||||
CAlarmSetMng::instance()->getActAndNum(m_act,m_num,m_style);
|
||||
CAlarmSetMng::instance()->getEngine(m_engine,m_language,m_voiceName);
|
||||
LOGDEBUG("获取当前语音引擎:%s-%s-%s",m_engine.toStdString().c_str(),m_language.toStdString().c_str(),m_voiceName.toStdString().c_str());
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::removeAudioCuesStop()
|
||||
{
|
||||
if(m_act == (int)E_ALARM_SOUND)
|
||||
{
|
||||
if(m_pMediaPlayer != NULL)
|
||||
{
|
||||
m_pMediaPlayer->stop();
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(m_pTextToSpeech != NULL)
|
||||
{
|
||||
m_pTextToSpeech->stop();
|
||||
emit m_pTextToSpeech->stateChanged(m_pTextToSpeech->state());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::insertAudioCuesStop(const AlarmMsgPtr &info)
|
||||
{
|
||||
if(m_act == (int)E_ALARM_SOUND && ALM_ACT_SOUND == (info->m_alarmAction & ALM_ACT_SOUND))
|
||||
{
|
||||
if(m_pMediaPlayer != NULL)
|
||||
{
|
||||
m_pMediaPlayer->stop();
|
||||
}
|
||||
}else if(m_act == (int)E_ALARM_VOICE && ALM_ACT_VOICE == (info->m_alarmAction & ALM_ACT_VOICE))
|
||||
{
|
||||
if(m_pTextToSpeech != NULL)
|
||||
{
|
||||
m_pTextToSpeech->stop();
|
||||
emit m_pTextToSpeech->stateChanged(m_pTextToSpeech->state());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::setVolumeEnable(bool bEnable)
|
||||
{
|
||||
if(bEnable)
|
||||
{
|
||||
m_voice = 100;
|
||||
if(m_pMediaPlayer != Q_NULLPTR)
|
||||
{
|
||||
m_pMediaPlayer->setVolume(m_voice);
|
||||
}
|
||||
|
||||
if(m_pTextToSpeech != Q_NULLPTR)
|
||||
{
|
||||
m_pTextToSpeech->setVolume(m_voice);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_voice = 0;
|
||||
if(m_pMediaPlayer != Q_NULLPTR)
|
||||
{
|
||||
m_pMediaPlayer->setVolume(m_voice);
|
||||
}
|
||||
|
||||
if(m_pTextToSpeech != Q_NULLPTR)
|
||||
{
|
||||
m_pTextToSpeech->setVolume(m_voice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::release()
|
||||
{
|
||||
LOGINFO("CAlarmMediaPlayer::release()");
|
||||
if(m_pMediaPlayer)
|
||||
{
|
||||
m_pMediaPlayer->stop();
|
||||
}
|
||||
if(m_pTextToSpeech)
|
||||
{
|
||||
m_pTextToSpeech->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::destory()
|
||||
{
|
||||
if(m_pMediaPlayer)
|
||||
{
|
||||
m_pMediaPlayer->disconnect();
|
||||
m_pMediaPlayer->stop();
|
||||
}
|
||||
if(m_pTextToSpeech)
|
||||
{
|
||||
m_pTextToSpeech->disconnect();
|
||||
m_pTextToSpeech->stop();
|
||||
}
|
||||
m_pInstance = NULL;
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::slotLoadConfig()
|
||||
{
|
||||
LOGINFO("CAlarmMediaPlayer::slotLoadConfig()");
|
||||
if(m_pMediaPlayer)
|
||||
{
|
||||
m_pMediaPlayer->disconnect();
|
||||
m_pMediaPlayer->stop();
|
||||
delete m_pMediaPlayer;
|
||||
m_pMediaPlayer = Q_NULLPTR;
|
||||
}
|
||||
if(m_pTextToSpeech)
|
||||
{
|
||||
m_pTextToSpeech->disconnect();
|
||||
m_pTextToSpeech->stop();
|
||||
delete m_pTextToSpeech;
|
||||
m_pTextToSpeech = Q_NULLPTR;
|
||||
}
|
||||
initSetCfg();
|
||||
|
||||
|
||||
if(m_act == (int)E_ALARM_SOUND)
|
||||
{
|
||||
initPlayer();
|
||||
updateAudioCuesPlayer();
|
||||
}else
|
||||
{
|
||||
initSpeech();
|
||||
updateAudioCuesSpeech();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::slotReadFlag()
|
||||
{
|
||||
LOGDEBUG("slotReadFlag");
|
||||
m_readFlag = true;
|
||||
|
||||
if(m_style != E_STYLE_NO_ALARM)
|
||||
{
|
||||
updateAudioCues();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::playerStateChanged(QMediaPlayer::State state)
|
||||
{
|
||||
if(m_act != (int)E_ALARM_SOUND)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
m_bChange = true;
|
||||
if(state == QMediaPlayer::StoppedState)
|
||||
{
|
||||
updateAudioCuesPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::speechStateChanged(QTextToSpeech::State state)
|
||||
{
|
||||
if(m_act != (int)E_ALARM_VOICE)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if(state == QTextToSpeech::Ready)
|
||||
{
|
||||
updateAudioCuesSpeech();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::updateAudioCuesPlayer()
|
||||
{
|
||||
if(!m_bHaveValidAudioDev || !m_pMediaPlayer || !m_readFlag || m_pMediaPlayer->state() != QMediaPlayer::StoppedState)
|
||||
{
|
||||
LOGDEBUG("CAlarmMediaPlayer::updateAudioCuesPlayer(),return");
|
||||
return;
|
||||
}
|
||||
AlarmMsgPtr info;
|
||||
if(m_style == E_STYLE_REPEAT)
|
||||
{
|
||||
info = CAlarmMsgManage::instance()->getOnePlayerAlm(-1);
|
||||
}
|
||||
else if(m_style == E_STYLE_REPEAT_X)
|
||||
{
|
||||
info = CAlarmMsgManage::instance()->getOnePlayerAlm(m_num);
|
||||
}
|
||||
if(info == Q_NULLPTR)
|
||||
{
|
||||
m_readFlag = false;
|
||||
return ;
|
||||
}
|
||||
QStringList strAudioFileNames = info->sound_file;
|
||||
|
||||
m_pMediaPlayer->playlist()->clear();
|
||||
foreach (QString fileName, strAudioFileNames)
|
||||
{
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
fileName = m_strMediaPath + fileName;
|
||||
if(QFile::exists(fileName))
|
||||
{
|
||||
m_pMediaPlayer->playlist()->addMedia(QUrl::fromLocalFile(fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!m_pMediaPlayer->playlist()->isEmpty())
|
||||
{
|
||||
m_pMediaPlayer->play();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::updateAudioCuesSpeech()
|
||||
{
|
||||
if(!m_bHaveValidAudioDev || !m_pTextToSpeech || !m_readFlag || m_pTextToSpeech->state() != QTextToSpeech::Ready)
|
||||
{
|
||||
LOGDEBUG("CAlarmMediaPlayer::updateAudioCuesSpeech(),return");
|
||||
return;
|
||||
}
|
||||
AlarmMsgPtr info;
|
||||
if(m_style == E_STYLE_REPEAT)
|
||||
{
|
||||
info = CAlarmMsgManage::instance()->getOneSpeechAlm(-1);
|
||||
}
|
||||
else if(m_style == E_STYLE_REPEAT_X)
|
||||
{
|
||||
info = CAlarmMsgManage::instance()->getOneSpeechAlm(m_num);
|
||||
}
|
||||
if(info == Q_NULLPTR)
|
||||
{
|
||||
m_readFlag = false;
|
||||
return ;
|
||||
}
|
||||
QString alarmContent = info->content;
|
||||
|
||||
if(!alarmContent.isEmpty())
|
||||
{
|
||||
m_pTextToSpeech->say(alarmContent);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::printError(QMediaPlayer::Error error)
|
||||
{
|
||||
if(m_pMediaPlayer)
|
||||
{
|
||||
LOGERROR("QMediaPlayer error == %d , errorString : %s",error,m_pMediaPlayer->errorString().toStdString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmMediaPlayer::checkAudioDev()
|
||||
{
|
||||
//< 周期性检测音频设备有效性,因为:
|
||||
//< 1、声卡是可以热拔插的,比如USB声卡
|
||||
//< 2、音频服务(比如Windows Audio系统服务)也是可以动态启停的
|
||||
|
||||
bool bHaveValidDev = false;
|
||||
|
||||
//< 注意:在win系统,qt5.9.9以及5.12.9上测试,下面使用QAudioDeviceInfo检测的方法,本身会导致内存上涨
|
||||
{
|
||||
// //< 测试结果:无论windows audio服务是否启动,defaultOutputDevice看上去都是对的,所以,不能用这个判断是否有效
|
||||
|
||||
// QList<QAudioDeviceInfo> listDev(QAudioDeviceInfo::availableDevices(QAudio::AudioOutput));
|
||||
|
||||
// //< 不能仅仅检测列表是否为空,还需要检测有效性
|
||||
// //< 当有声卡硬件,但是Windows Audio服务未启动时,设备列表不为空,但如果播放依然可能导致内存上涨问题
|
||||
// foreach (QAudioDeviceInfo objDev, listDev)
|
||||
// {
|
||||
// //< 当Window Audio服务未启动时,无法获取有效的格式信息,以此判断
|
||||
// if(objDev.preferredFormat().isValid())
|
||||
// {
|
||||
// bHaveValidDev = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
//< 不得已,使用win系统原生API条件编译
|
||||
#ifdef OS_WINDOWS
|
||||
{
|
||||
//< 获取系统默认主设备的音量,如果成功则至少说明:
|
||||
//< 1、有声卡; 2、Windows Audio服务正常
|
||||
|
||||
CoInitialize(NULL);
|
||||
IMMDeviceEnumerator *pDevEnumerator = NULL;
|
||||
CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_INPROC_SERVER, __uuidof(IMMDeviceEnumerator), (LPVOID *)&pDevEnumerator);
|
||||
|
||||
if(NULL != pDevEnumerator)
|
||||
{
|
||||
IMMDevice *pDefaultDev = NULL;
|
||||
pDevEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &pDefaultDev);
|
||||
|
||||
pDevEnumerator->Release();
|
||||
pDevEnumerator = NULL;
|
||||
|
||||
if(NULL != pDefaultDev)
|
||||
{
|
||||
IAudioEndpointVolume *pEndpointVol = NULL;
|
||||
pDefaultDev->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, NULL, (LPVOID *)&pEndpointVol);
|
||||
|
||||
pDefaultDev->Release();
|
||||
pDefaultDev = NULL;
|
||||
|
||||
if(NULL != pEndpointVol)
|
||||
{
|
||||
float fVol;
|
||||
const HRESULT nResult = pEndpointVol->GetMasterVolumeLevelScalar(&fVol);
|
||||
if(S_OK == nResult)
|
||||
bHaveValidDev = true;
|
||||
|
||||
pEndpointVol->Release();
|
||||
pEndpointVol = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CoUninitialize();
|
||||
}
|
||||
#else
|
||||
//< 在Linux系统下测试,即使没有声卡也未见问题,暂时不做检测
|
||||
bHaveValidDev = true;
|
||||
#endif
|
||||
if(m_act == (int)E_ALARM_SOUND) //
|
||||
{
|
||||
if(m_bHaveValidAudioDev && !bHaveValidDev)
|
||||
{
|
||||
LOGERROR("No valid audio output device !");
|
||||
m_bHaveValidAudioDev = false;
|
||||
if(m_pMediaPlayer != Q_NULLPTR)
|
||||
{
|
||||
m_pMediaPlayer->disconnect();
|
||||
m_pMediaPlayer->stop();
|
||||
delete m_pMediaPlayer;
|
||||
m_pMediaPlayer = Q_NULLPTR;
|
||||
}
|
||||
}
|
||||
else if(!m_bHaveValidAudioDev && bHaveValidDev)
|
||||
{
|
||||
LOGINFO("Valid audio output device detected !");
|
||||
|
||||
//< 不重新构造可能不能正常播放
|
||||
if(m_pMediaPlayer)
|
||||
{
|
||||
m_pMediaPlayer->disconnect();
|
||||
delete m_pMediaPlayer;
|
||||
m_pMediaPlayer = Q_NULLPTR;
|
||||
}
|
||||
|
||||
m_bHaveValidAudioDev = true;
|
||||
initPlayer();
|
||||
updateAudioCuesPlayer();
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(m_bHaveValidAudioDev && !bHaveValidDev)
|
||||
{
|
||||
LOGERROR("No valid audio output device !");
|
||||
m_bHaveValidAudioDev = false;
|
||||
if(m_pTextToSpeech != Q_NULLPTR)
|
||||
{
|
||||
m_pTextToSpeech->disconnect();
|
||||
m_pTextToSpeech->stop();
|
||||
delete m_pTextToSpeech;
|
||||
m_pTextToSpeech = Q_NULLPTR;
|
||||
}
|
||||
}
|
||||
else if(!m_bHaveValidAudioDev && bHaveValidDev)
|
||||
{
|
||||
LOGINFO("Valid audio output device detected !");
|
||||
|
||||
//< 不重新构造可能不能正常播放
|
||||
if(m_pTextToSpeech)
|
||||
{
|
||||
m_pTextToSpeech->disconnect();
|
||||
m_pTextToSpeech->stop();
|
||||
delete m_pTextToSpeech;
|
||||
m_pTextToSpeech = Q_NULLPTR;
|
||||
}
|
||||
m_bHaveValidAudioDev = true;
|
||||
initSpeech();
|
||||
updateAudioCuesSpeech();
|
||||
}
|
||||
}
|
||||
}
|
||||
//因QMediaPlayer自身bug问题 此处只检测QMediaPlayer
|
||||
void CAlarmMediaPlayer::checkAudioStatus()
|
||||
{
|
||||
if(!m_readFlag)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if(m_act == (int)E_ALARM_VOICE) //语音告警无需检测
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if(!m_bChange)
|
||||
{
|
||||
//< 不重新构造可能不能正常播放
|
||||
if(m_pMediaPlayer)
|
||||
{
|
||||
m_pMediaPlayer->disconnect();
|
||||
m_pMediaPlayer->stop();
|
||||
delete m_pMediaPlayer;
|
||||
m_pMediaPlayer = Q_NULLPTR;
|
||||
}
|
||||
m_bHaveValidAudioDev = true;
|
||||
initPlayer();
|
||||
updateAudioCuesPlayer();
|
||||
}
|
||||
m_bChange = false;
|
||||
}
|
||||
99
product/src/gui/plugin/AlarmWidget_pad/CAlarmMediaPlayer.h
Normal file
99
product/src/gui/plugin/AlarmWidget_pad/CAlarmMediaPlayer.h
Normal file
@ -0,0 +1,99 @@
|
||||
#ifndef CALARMMEDIAPLAYER_H
|
||||
#define CALARMMEDIAPLAYER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QMediaPlayer>
|
||||
#include <QTimer>
|
||||
#include "CAlarmMsgInfo.h"
|
||||
#include <QTextToSpeech>
|
||||
|
||||
//< 告警语音最大条数
|
||||
//extern const int MAX_AUDIO_COUNT;
|
||||
|
||||
class CAlarmMediaPlayer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static CAlarmMediaPlayer * instance();
|
||||
~CAlarmMediaPlayer();
|
||||
|
||||
/**
|
||||
* @brief slotAudioCuesEnable 静音使能
|
||||
* @param bEnable
|
||||
*/
|
||||
void setVolumeEnable(bool bEnable);
|
||||
|
||||
void release();
|
||||
|
||||
public slots:
|
||||
void destory();
|
||||
void slotLoadConfig();
|
||||
|
||||
void slotReadFlag();
|
||||
|
||||
private:
|
||||
CAlarmMediaPlayer();
|
||||
|
||||
void updateAudioCues();
|
||||
/**
|
||||
* @brief updateAudioCuesPlayer 更新播放文件
|
||||
*/
|
||||
void updateAudioCuesPlayer();
|
||||
|
||||
void updateAudioCuesSpeech();
|
||||
|
||||
void initPlayer();
|
||||
|
||||
void initSpeech();
|
||||
|
||||
void initSetCfg();
|
||||
|
||||
void removeAudioCuesStop();
|
||||
|
||||
void insertAudioCuesStop(const AlarmMsgPtr &info);
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief playerStateChanged 播放器状态变化
|
||||
*/
|
||||
void playerStateChanged(QMediaPlayer::State state);
|
||||
|
||||
void speechStateChanged(QTextToSpeech::State state);
|
||||
|
||||
void printError(QMediaPlayer::Error error);
|
||||
|
||||
void checkAudioDev();
|
||||
|
||||
void checkAudioStatus();
|
||||
private:
|
||||
//< 机器有有效的音频输出设备
|
||||
//< 如果没有输出设备,会导致内存上涨,在Windows Server 2016上实测如此
|
||||
bool m_bHaveValidAudioDev;
|
||||
static CAlarmMediaPlayer * m_pInstance;
|
||||
QString m_strMediaPath;
|
||||
QMediaPlayer *m_pMediaPlayer;
|
||||
QTextToSpeech *m_pTextToSpeech;
|
||||
|
||||
//< 周期性检测音频设备有效性,因为:
|
||||
//< 1、声卡是可以热拔插的,比如USB声卡
|
||||
//< 2、音频服务(比如Windows Audio系统服务)也是可以动态启停的
|
||||
QTimer *m_pTimerCheckAudioDev;
|
||||
QTimer *m_pTimerCheckAudioStatus;
|
||||
int m_voice; //语音大小
|
||||
bool m_bChange;
|
||||
|
||||
int m_act;
|
||||
int m_num;
|
||||
int m_style;
|
||||
|
||||
QString m_engine;
|
||||
QString m_language;
|
||||
QString m_voiceName;
|
||||
|
||||
bool m_readFlag;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // CALARMMEDIAPLAYER_H
|
||||
1189
product/src/gui/plugin/AlarmWidget_pad/CAlarmMsgInfo.cpp
Normal file
1189
product/src/gui/plugin/AlarmWidget_pad/CAlarmMsgInfo.cpp
Normal file
File diff suppressed because it is too large
Load Diff
88
product/src/gui/plugin/AlarmWidget_pad/CAlarmMsgInfo.h
Normal file
88
product/src/gui/plugin/AlarmWidget_pad/CAlarmMsgInfo.h
Normal file
@ -0,0 +1,88 @@
|
||||
#ifndef ALARMMSGINFO_H
|
||||
#define ALARMMSGINFO_H
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QStringList>
|
||||
#include <QSharedPointer>
|
||||
#include "alarm_server_api/CAlmApiForAlmClt.h"
|
||||
#include "CAlarmCommon.h"
|
||||
//< 告警操作 权限定义
|
||||
#define FUNC_SPE_ALARM_OPERATE ("FUNC_SPE_ALARM_OPERATE")
|
||||
#define FUNC_SPE_ALARM_DELETE ("FUNC_SPE_ALARM_DELETE")
|
||||
// 逻辑状态
|
||||
enum E_ALARM_LOGICSTATE
|
||||
{
|
||||
E_ALS_ALARM = 0, // 告警状态
|
||||
E_ALS_ALARM_CFM =1, // 告警确认状态
|
||||
E_ALS_RETURN=2, // 告警返回状态
|
||||
E_ALS_RETURN_CFM=3, // 告警返回确认状态
|
||||
ALS_EVT_ONLY = 4, // 仅事件
|
||||
|
||||
//在原始告警窗删除后,可能还需要在智能告警窗展示
|
||||
E_ALS_ALARM_DEL = 20, // 告警状态,且在原始告警窗已删除,可能是达到数量上限而删除
|
||||
E_ALS_ALARM_CFM_DEL =21, // 告警确认状态,且在原始告警窗已删除
|
||||
E_ALS_RETURN_DEL=22, // 告警返回状态,且在原始告警窗已删除,可能是达到数量上限而删除
|
||||
E_ALS_RETURN_CFM_DEL=23, // 告警返回确认状态,且在原始告警窗已删除
|
||||
E_ALS_BAD = 100
|
||||
};
|
||||
class CAlarmMsgInfo
|
||||
{
|
||||
public:
|
||||
CAlarmMsgInfo();
|
||||
CAlarmMsgInfo(const CAlarmMsgInfo &other);
|
||||
void initialize(const iot_idl::SAlmInfoToAlmClt &alarmInfo);
|
||||
int getCameraInfoByTag(const QString &tag);
|
||||
|
||||
//< [优先级越小表示越大]-原始告警窗调用
|
||||
bool lessThan(const AlarmMsgPtr &info, E_ALARM_SORTKEY sortkey = E_SORT_PRIORITY);
|
||||
bool moreThan(const AlarmMsgPtr &info, E_ALARM_SORTKEY sortkey = E_SORT_PRIORITY);
|
||||
|
||||
//< [优先级越小表示越大]-智能告警窗调用
|
||||
bool ailessThan(const AlarmMsgPtr &info, E_ALARM_SORTKEY sortkey = E_SORT_PRIORITY);
|
||||
bool aimoreThan(const AlarmMsgPtr &info, E_ALARM_SORTKEY sortkey = E_SORT_PRIORITY);
|
||||
|
||||
bool ailessThan(const AiAlarmMsgPtr &info, E_ALARM_SORTKEY sortkey = E_SORT_PRIORITY);
|
||||
bool aimoreThan(const AiAlarmMsgPtr &info, E_ALARM_SORTKEY sortkey = E_SORT_PRIORITY);
|
||||
qint32 alm_type; //< 告警类型
|
||||
int alm_status; //< 告警状态
|
||||
E_ALARM_LOGICSTATE logic_state; //< 逻辑状态
|
||||
quint64 time_stamp; //< 时标(RFC1305、POSIX时标标准)
|
||||
qint32 domain_id; //< 域ID
|
||||
qint32 location_id; //< 位置ID
|
||||
qint32 app_id; //< 应用号
|
||||
qint32 priority; //< 告警优先级id
|
||||
qint32 if_water_alm; //< 是否流水账告警(0 替换式告警,1 流水账告警)
|
||||
QString uuid_base64; //< uuid 主键
|
||||
QString content; //< 告警内容
|
||||
QStringList sound_file; //< 语音文件名
|
||||
//可选
|
||||
qint32 sub_system; //< 专业
|
||||
qint32 dev_type; //< 设备类型ID
|
||||
qint32 region_id; //< 责任区ID
|
||||
QString dev_group_tag; //< 设备组
|
||||
QString key_id_tag; //< 测点ID
|
||||
QString graph_name; //< 告警关联画面名称
|
||||
QString wave_file; //< 录波画面
|
||||
//< Extend
|
||||
qint32 priorityOrder; //< 优先级
|
||||
QString device; //< 设备 (保留)
|
||||
bool deleteFlag; //< 是否被删除
|
||||
bool releaseFlag; //< 释放标志
|
||||
bool m_needVideoAlm; //< 是否需要视频告警
|
||||
QString m_camera;
|
||||
QString m_preset;
|
||||
E_TAGNAME_TYPE m_tagname_type;
|
||||
|
||||
|
||||
//程序使用
|
||||
int m_playNum; // 播放次数 默认0次
|
||||
int m_alarmAction; //此告警对应的告警动作
|
||||
|
||||
};
|
||||
|
||||
bool operator==(const CAlarmMsgInfo &source, const CAlarmMsgInfo &target);
|
||||
|
||||
Q_DECLARE_METATYPE(CAlarmMsgInfo)
|
||||
Q_DECLARE_METATYPE(AlarmMsgPtr)
|
||||
|
||||
#endif // ALARMMSGINFO_H
|
||||
1896
product/src/gui/plugin/AlarmWidget_pad/CAlarmMsgManage.cpp
Normal file
1896
product/src/gui/plugin/AlarmWidget_pad/CAlarmMsgManage.cpp
Normal file
File diff suppressed because it is too large
Load Diff
420
product/src/gui/plugin/AlarmWidget_pad/CAlarmMsgManage.h
Normal file
420
product/src/gui/plugin/AlarmWidget_pad/CAlarmMsgManage.h
Normal file
@ -0,0 +1,420 @@
|
||||
#ifndef CALARMMSGMANAGE_H
|
||||
#define CALARMMSGMANAGE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
#include "CAlarmMsgInfo.h"
|
||||
#include "CAiAlarmMsgInfo.h"
|
||||
#include "dbms/rdb_api/CRdbAccess.h"
|
||||
|
||||
#include "CAlarmCommon.h"
|
||||
#include <QMap>
|
||||
|
||||
const int MAX_AUDIO_ALM_COUNT = 1000;
|
||||
|
||||
class QMutex;
|
||||
class CAlarmItemModel;
|
||||
class CAlarmMsgManage : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static CAlarmMsgManage * instance();
|
||||
|
||||
~CAlarmMsgManage();
|
||||
|
||||
void destory();
|
||||
|
||||
void initialize();
|
||||
|
||||
void release();
|
||||
|
||||
QList<AlarmMsgPtr> getListAlarmInfo();
|
||||
|
||||
QHash<QString, int> getDeviceStatisticalInfo();
|
||||
|
||||
int deviceGroupAlarmStatistical(const QString &deviceGroup);
|
||||
|
||||
int getAlarmTotalSize();
|
||||
|
||||
int getUnConfirmSize();
|
||||
|
||||
void output();
|
||||
|
||||
void addAlarmMsg(const QList<AlarmMsgPtr> &msgList);
|
||||
|
||||
void addAlarmToAllInfo(const QList<AlarmMsgPtr> &msgList);
|
||||
|
||||
void addAlarmCacheMsg(const QList<AlarmMsgPtr> &msgList);
|
||||
|
||||
void confirmAlarmMsg(const QList<QString> &uuidList);
|
||||
|
||||
int removeAlarmMsg(const QList<QString> &uuidList);
|
||||
|
||||
void releaseAlarmMsg(const QList<QString> &uuidList);
|
||||
|
||||
void linkWave2AlmMsg(const QList<QString> &uuidList,const QString &waveFile);
|
||||
|
||||
void removeAlarmMsgByDomainID(const int &domainId);
|
||||
|
||||
void updateMsgAction(const QList<AlarmMsgPtr> &msgList);
|
||||
void updateMsgAction(const AlarmMsgPtr &msg);
|
||||
//< 告警动作
|
||||
void pushGraphics(const QString &info);
|
||||
void print();
|
||||
void shortMessage();
|
||||
void sounds(const AlarmMsgPtr info, const QStringList soundFileNames);
|
||||
void stopSounds(const AlarmMsgPtr info);
|
||||
void paNotify();
|
||||
|
||||
bool isBindMediaPlayer();
|
||||
void msgArrived();
|
||||
void dealDelayAi();
|
||||
|
||||
void addInhibitAlm(const AlarmMsgPtr &info);
|
||||
void removeInhibitTag(const QString &tag_name);
|
||||
QMap<int,int > getDevAlarm(const QString &device);
|
||||
|
||||
QMap<int,QList<QString> >getDevGroupPriorityDevNum(const QString &deviceGroup);
|
||||
|
||||
QHash<int,QMap<int,int> > getLocAlmInfo();
|
||||
void updataDevGroupByDev(QString devGroup, QString device);
|
||||
|
||||
QHash<int,QMap<QString,QSet<QString> > > getLocNotConfirmAlmInfo();
|
||||
|
||||
void getAllInhibitAlm(QList<AlarmMsgPtr> &almList);
|
||||
signals:
|
||||
void sigInsertAudioCues(const AlarmMsgPtr &info, const QStringList &soundFileNames);
|
||||
void sigStopAudioCues(const AlarmMsgPtr &info);
|
||||
void sigAlarmPushGraph(const QString &alarmInfo);
|
||||
void sigAlarmPushGraphClear();
|
||||
void sigAlarmReplaced();
|
||||
void sigMsgArrived(QList<AlarmMsgPtr> listMsg); //只通知表格模型
|
||||
/**
|
||||
* @brief sigMsgArrivedToAi 通知树模型未聚类的原始告警到达
|
||||
* @param listMsg
|
||||
*/
|
||||
void sigMsgArrivedToAi(QList<AlarmMsgPtr> listMsg); //只通知树模型
|
||||
|
||||
void sigAllViewReload();
|
||||
|
||||
void sigReadFlag();
|
||||
|
||||
public slots:
|
||||
void slotLogin();
|
||||
|
||||
private:
|
||||
CAlarmMsgManage();
|
||||
int queryAlarmAction(const int &priority);
|
||||
QString queryLocationDescription(int id);
|
||||
QString queryAppDescription(int id);
|
||||
|
||||
void loadPermInfo();
|
||||
|
||||
void refreshCache();
|
||||
|
||||
public:
|
||||
bool ifInhibit(const QString &tag_name);
|
||||
bool isInhibit(const QString &tag_name);
|
||||
/**
|
||||
* @brief removeAiAlarmMsgByDomainID 移除此域所有智能告警,并清除,维护相关结构
|
||||
* @param domainId 域id
|
||||
*/
|
||||
void removeAiAlarmMsgByDomainID(const int &domainId);
|
||||
/**
|
||||
* @brief addAiAllAlarmMsg 全数据时调用,不会通知模型,全部接收完会自动通知模型刷新(重新装载数据)
|
||||
* @param msg 智能告警指针
|
||||
*/
|
||||
void addAiAllAlarmMsg(const QList<AiAlarmMsgPtr> &msgList);
|
||||
/**
|
||||
* @brief addAiAlarmMsg 非全数据时调用,会通知模型添加智能告警,删除相关原始告警
|
||||
* @param msg 智能告警指针
|
||||
*/
|
||||
void addAiAlarmMsg(const QList<AiAlarmMsgPtr> &msgList);
|
||||
/**
|
||||
* @brief delAiAlarmMsg 根据智能告警uuid删除智能告警
|
||||
* @param aiuuid 智能告警uuid
|
||||
*/
|
||||
void delAiAlarmMsg(const QList<QString> &uuidList);
|
||||
/**
|
||||
* @brief brokenAiAlarmMsg 处理不完整的智能告警
|
||||
* @param aiuuid
|
||||
*/
|
||||
void brokenAiAlarmMsg(const QList<QString> &uuidList);
|
||||
/**
|
||||
* @brief releaseAiAlarmMsg 根据智能告警uuid释放智能告警
|
||||
* @param aiuuid 智能告警uuid
|
||||
*/
|
||||
void releaseAiAlarmMsg(const QList<QString> &uuidList);
|
||||
/**
|
||||
* @brief getAiuuid 根据原始告警uuid获取智能告警uuid
|
||||
* @param uuid 原始告警uuid
|
||||
* @param aiuuid 智能告警uuid
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
bool getAiuuid(const QString &uuid, QString &aiuuid);
|
||||
/**
|
||||
* @brief isBelongAi 是否属于某个智能告警(已经被某个智能告警聚类)
|
||||
* @param uuid 原始告警uuid
|
||||
* @return true-已经被聚类 false-还未被聚类
|
||||
*/
|
||||
bool isBelongAi(const QString &uuid);
|
||||
|
||||
AlarmMsgPtr getOnePlayerAlm(int num);
|
||||
|
||||
AlarmMsgPtr getOneSpeechAlm(int num);
|
||||
private:
|
||||
/**
|
||||
* @brief eraseaicount 删除key为aiuuid的键值对 (<智能告警id,SAiConfirm>)
|
||||
* @param aiuuid 智能告警uuid
|
||||
*/
|
||||
void eraseaicount(const QString &aiuuid);
|
||||
/**
|
||||
* @brief eraseidtoid 删除值为aiuuid的所有键值对(<原始告警id,智能告警id>)
|
||||
* @param aiuuid 智能告警uuid
|
||||
*/
|
||||
void eraseidtoid(const QString &aiuuid);
|
||||
/**
|
||||
* @brief eraseidtolocation 删除key为aiuuid的键值对 (<智能告警id,与此条智能告警相关的所有位置id>)
|
||||
* @param aiuuid 智能告警uuid
|
||||
*/
|
||||
void eraseidtolocation(const QString &aiuuid);
|
||||
/**
|
||||
* @brief isHaveAlm 查询m_all中是否包含uuidVec中的告警(确保智能告警下的原始告警一定存在)
|
||||
* @param uuidVec
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* @brief isHaveAlm isHaveAlm 查询m_all中是否包含uuidVec中的告警(确保智能告警下的原始告警一定存在)
|
||||
* @param uuidVec 原始告警uuid集合
|
||||
* @param almInfoList 原始告警智能指针集合
|
||||
* @return 全部包含返回true,否则返回false
|
||||
*/
|
||||
bool isHaveAlm(const QVector<QString> &uuidVec, QList<AlarmMsgPtr> &almInfoList);
|
||||
/**
|
||||
* @brief checkLookPerm 检查当前登陆用户是否具有此条智能告警的权限(若可以看到其中任意一条,则具有权限)
|
||||
* @param uuidVec 智能告警下原始告警uuid集合
|
||||
* @return 有权限返回 true 否则返回false
|
||||
*/
|
||||
/**
|
||||
* @brief checkLookPerm checkLookPerm 检查当前登陆用户是否具有此条智能告警的权限(若可以看到其中任意一条,则具有权限)
|
||||
* @param almInfoList 原始告警智能指针集合
|
||||
* @return 具有权限返回true 否则返回false
|
||||
*/
|
||||
bool checkLookPerm(const QList<AlarmMsgPtr> &almInfoList);
|
||||
/**
|
||||
* @brief addidtoid 添加原始告警uuid和智能告警uuid的映射
|
||||
* @param uuidVec 原始告警uuid集合
|
||||
* @param aiuuid 智能告警uuid
|
||||
*/
|
||||
void addidtoid(const QVector<QString> &uuidVec, const QString &aiuuid);
|
||||
/**
|
||||
* @brief addaicount 添加智能告警下原始告警的已确认和总数
|
||||
* @param uuidVec 原始告警uuid集合
|
||||
* @param aiuuid 智能告警uuid
|
||||
*/
|
||||
/**
|
||||
* @brief addaicount 添加智能告警下原始告警的已确认和总数
|
||||
* @param almInfoList 原始告警智能指针的集合
|
||||
* @param aiuuid 智能告警aiuuid
|
||||
*/
|
||||
void addaicount(const QList<AlarmMsgPtr> &almInfoList, const QString &aiuuid);
|
||||
/**
|
||||
* @brief addaitolocation addaitolocation 添加智能告警uuid和与此告警相关位置的id
|
||||
* @param almInfoList 原始告警智能指针集合
|
||||
* @param aiuuid 智能告警aiuuid
|
||||
*/
|
||||
void addaitolocation(const QList<AlarmMsgPtr> &almInfoList, const QString &aiuuid);
|
||||
/**
|
||||
* @brief initaivideo initaivideo 初始化智能告警下原始告警的相关信息
|
||||
* @param msg
|
||||
*/
|
||||
void initaivideo(AiAlarmMsgPtr msg);
|
||||
/**
|
||||
* @brief updatealarm 更新需要展示在智能告警窗上未聚类的原始告警
|
||||
* @param uuidVec 某条智能告警下的所有原始告警的uuid
|
||||
* @param deluuidVec 需要被删除的一级节点上的未聚类的原始告警uuid
|
||||
*/
|
||||
void updatealarm(QVector<QString> &uuidVec, QVector<QString> &deluuidVec);
|
||||
/**
|
||||
* @brief almStats 告警统计
|
||||
* @param msg 告警指针
|
||||
* @param addOrSub 1--add 0--sub(1添加,0删除)
|
||||
*/
|
||||
void almStats(const AlarmMsgPtr &msg,int addOrSub);
|
||||
/**
|
||||
* @brief almAddStats 告警添加统计
|
||||
* @param msg 告警指针
|
||||
*/
|
||||
void almAddStats(const AlarmMsgPtr &msg);
|
||||
/**
|
||||
* @brief almSubStats 告警删除统计
|
||||
* @param msg 告警指针
|
||||
*/
|
||||
void almSubStats(const AlarmMsgPtr &msg);
|
||||
/**
|
||||
* @brief devDevGTotAlmAddStats 设备设备组按优先级添加统计
|
||||
* @param msg 告警指针
|
||||
*/
|
||||
void devDevGTotAlmAddStats(const AlarmMsgPtr &msg);
|
||||
/**
|
||||
* @brief devDevGTotAlmSubStats 设备设备组按优先级删除统计
|
||||
* @param msg 告警指针
|
||||
*/
|
||||
void devDevGTotAlmSubStats(const AlarmMsgPtr &msg);
|
||||
void devDevGAddStats(const AlarmMsgPtr &msg);
|
||||
void devDevGSubStats(const AlarmMsgPtr &msg);
|
||||
void locAddStats(const AlarmMsgPtr &msg);
|
||||
void locSubStats(const AlarmMsgPtr &msg);
|
||||
/**
|
||||
* @brief addNotConfirmAlm 添加未确认的告警uuid
|
||||
* @param locId
|
||||
* @param devg
|
||||
* @param uuid
|
||||
*/
|
||||
void addNotConfirmAlm(int locId,const QString &devg,const QString &uuid);
|
||||
/**
|
||||
* @brief delNotConfirmAlm 从未确认的告警uuid集合中删除(删除的不一定被确认 可能是数据重发)
|
||||
* @param locId
|
||||
* @param devg
|
||||
* @param uuid
|
||||
*/
|
||||
void delNotConfirmAlm(int locId,const QString &devg,const QString &uuid);
|
||||
signals:
|
||||
/**
|
||||
* @brief sigAiMsgRemove 通知智能告警模型删除智能告警
|
||||
* @param aiuuidList 智能告警aiuuid列表
|
||||
*/
|
||||
void sigAiMsgRemove(const QList<QString> & aiuuidList);
|
||||
/**
|
||||
* @brief sigAiMsgAdd 通知智能告警模型添加某条智能告警
|
||||
* @param aimsgList 智能告警指针列表
|
||||
*/
|
||||
void sigAiMsgAdd(const QList<AiAlarmMsgPtr>& aimsgList);
|
||||
/**
|
||||
* @brief sigMsgRemove 通知智能告警模型删除一级节点上的原始告警
|
||||
* @param deluuid 需要删除的原始告警uuid的集合
|
||||
*/
|
||||
void sigMsgRemove(const QVector<QString> deluuid);
|
||||
public:
|
||||
/**
|
||||
* @brief queryLocationDesc 根据智能告警uuid查询位置描述(可能包含多个位置)
|
||||
* @param aiuuid 智能告警uuid
|
||||
* @return 位置描述
|
||||
*/
|
||||
QString queryLocationDesc(QString &aiuuid);
|
||||
/**
|
||||
* @brief queryConfirm 根据智能告警uuid查询确认数和总数
|
||||
* @param aiuuid 智能告警uuid
|
||||
* @return 确认数/总数(ex:20/30)
|
||||
*/
|
||||
QString queryConfirm(const QString &aiuuid);
|
||||
/**
|
||||
* @brief queryAiTotal 根据智能告警uuid 查询原始告警条数
|
||||
* @param aiuuid 智能告警uuid
|
||||
* @return 原始告警条数
|
||||
*/
|
||||
int queryAiTotal(const QString &aiuuid);
|
||||
/**
|
||||
* @brief getAlarmInfo 获取所有有权限的原始告警和智能告警 (接口:给智能告警模型使用)
|
||||
* @param listAlarm 原始告警指针集合
|
||||
* @param listaiAlarm 智能告警指针集合
|
||||
*/
|
||||
void getAlarmInfo(QList<AlarmMsgPtr> &listAlarm,QList<AiAlarmMsgPtr> &listaiAlarm);
|
||||
/**
|
||||
* @brief getAlarmPtrByuuid 根据原始告警uuid获取原始告警指针
|
||||
* @param uuid 原始告警uuid列表
|
||||
* @return 原始告警指针列表
|
||||
*/
|
||||
QList<AlarmMsgPtr> getAlarmPtrByuuid(const QVector<QString> &uuidVec);
|
||||
/**
|
||||
* @brief ifhaveNotConfirmAlmByuuid 根据智能告警uuid查询是否还有未确认的原始告警
|
||||
* @param aiuuid 智能告警uuid
|
||||
* @return 如果包含未确认原始告警返回true,否则返回false
|
||||
*/
|
||||
bool ifhaveNotConfirmAlmByuuid(QString &aiuuid);
|
||||
/**
|
||||
* @brief getAiLocationList 根据智能告警uuid获取有关的位置集合
|
||||
* @param aiuuid 智能告警uuid
|
||||
* @return 与之有关的位置集合
|
||||
*/
|
||||
QList<int> getAiLocationList(QString &aiuuid);
|
||||
/**
|
||||
* @brief getalmuuidByAiuuid 根据智能告警uuid获取相关原始告警uuid
|
||||
* @param aiuuid 智能告警uuid
|
||||
* @return 原始告警uuidList
|
||||
*/
|
||||
QList<QString> getalmuuidByAiuuid(const QString &aiuuid);
|
||||
/**
|
||||
* @brief getAlmTotal 获取智能告警窗显示原始告警总数
|
||||
* @return 数量
|
||||
*/
|
||||
int getAlmTotal();
|
||||
/**
|
||||
* @brief getAiCount 获取未过滤时的智能告警条数
|
||||
* @return
|
||||
*/
|
||||
int getAiCount();
|
||||
|
||||
private:
|
||||
|
||||
void initAlarm();
|
||||
|
||||
void initAiAlarm();
|
||||
|
||||
void insertAudioCues(const AlarmMsgPtr &info);
|
||||
|
||||
void removeAudioCues(const AlarmMsgPtr &info);
|
||||
|
||||
void setReadFlag();
|
||||
|
||||
private:
|
||||
static CAlarmMsgManage * pInstance;
|
||||
|
||||
QMutex * mutex;
|
||||
|
||||
iot_dbms::CRdbAccess * m_rtdbAlarmActionAccess;
|
||||
iot_dbms::CRdbAccess * m_rtdbLocationDescriptionAccess;
|
||||
iot_dbms::CRdbAccess * m_rtdbAppDescriptionAccess;
|
||||
|
||||
int m_nNDelComAlarmCount; //< 未删除未确认数量 N--not Del--delete Com--confirm
|
||||
QHash<QString, AlarmMsgPtr> m_infos;
|
||||
QHash<QString, AlarmMsgPtr> m_all;
|
||||
|
||||
|
||||
QList<int> m_listPermLocationId; //< 原始告警车站权限
|
||||
QList<int> m_listPermRegionId; //< 原始告警责任区权限
|
||||
|
||||
|
||||
//缓存从collect调整到mng
|
||||
QList<AlarmMsgPtr> m_listMsgAddCache; //< 告警缓存(每秒更新)
|
||||
QList<AlarmMsgPtr> m_inhibitFilter; //< 告警抑制[界面]
|
||||
|
||||
//智能告警新加
|
||||
QHash<QString, AlarmMsgPtr> m_alarm; //< 有权限/未禁止/未聚类的原始告警(需要展示在智能告警窗)(两个线程共同维护)
|
||||
QHash<QString, AiAlarmMsgPtr> m_aiinfos; //< 有权限的智能告警
|
||||
QHash<QString, AiAlarmMsgPtr> m_aiall; //< 所有智能告警
|
||||
|
||||
QHash<QString,SAiConfirm> m_aicount; //< <智能告警uuid,已确认数/总数 >
|
||||
QHash<QString,QString> m_idToid; //< <原始告警uuid,智能告警uuid > 用于确认原始告警之后便于更新智能告警中的已确认总数
|
||||
|
||||
QHash<QString,QList<int> > m_aitolocation;//< <智能告警uuid,包含的原始告警车站id>
|
||||
|
||||
QHash<QString, int> m_alarmDeviceStatistical; //< 设备告警数量统计
|
||||
QHash<QString, int> m_alarmDeviceGroupStatistical; //<设备组告警数量统计
|
||||
QHash<QString, QMap<int,int> > m_alarmDevPriority; //< 设备告警等级数量统计
|
||||
QHash<QString, QMap<int,QList<QString> > > m_alarmDGPDev; //< <设备组,<告警等级,设备> >
|
||||
QHash<int,QMap<int,int > > m_alarmLPAlm; //< <车站id,<告警等级,告警数量> >
|
||||
|
||||
QHash<int,QMap<QString,QSet<QString> > > m_alarmLNCAlm;//< <车站id,<设备组,<未确认告警uuid> > >
|
||||
|
||||
QList<AiAlarmMsgPtr> m_delaydeal; //延迟处理的智能告警
|
||||
|
||||
int m_nAlmNum; //智能告警窗原始告警个数
|
||||
int m_nAlmTotal; //智能告警窗原始告警总数
|
||||
|
||||
QList<AlarmMsgPtr> m_playerList;
|
||||
|
||||
QString m_strMediaPath;
|
||||
};
|
||||
|
||||
#endif // CALARMMSGMANAGE_H
|
||||
1445
product/src/gui/plugin/AlarmWidget_pad/CAlarmPlugin.cpp
Normal file
1445
product/src/gui/plugin/AlarmWidget_pad/CAlarmPlugin.cpp
Normal file
File diff suppressed because it is too large
Load Diff
361
product/src/gui/plugin/AlarmWidget_pad/CAlarmPlugin.h
Normal file
361
product/src/gui/plugin/AlarmWidget_pad/CAlarmPlugin.h
Normal file
@ -0,0 +1,361 @@
|
||||
#ifndef CALARMPLUGIN_H
|
||||
#define CALARMPLUGIN_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "CAlarmMsgInfo.h"
|
||||
#include "CAlarmItemModel.h"
|
||||
#include "CAlarmMediaPlayer.h"
|
||||
#include "CAlarmSetMng.h"
|
||||
#include "CAiAlarmTreeModel.h"
|
||||
class CAlarmView;
|
||||
class CAlarmForm;
|
||||
class CAlarmWidget;
|
||||
class CAlarmItemModel;
|
||||
|
||||
class CAlarmPlugin : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CAlarmPlugin(QWidget *parent, bool editMode = false);
|
||||
~CAlarmPlugin();
|
||||
|
||||
int confirmAlarm(const QList<AlarmMsgPtr> &msgs);
|
||||
|
||||
int removeAlarm(const QList<AlarmMsgPtr> &msgs);
|
||||
|
||||
public slots:
|
||||
/*************************以下接口为公共接口*****************************/
|
||||
/**
|
||||
* @brief initialize 初始化模型
|
||||
* @param mode E_Alarm_Dock-小窗(0) E_Alarm_Window-大窗(1) E_Alarm_Pop-弹窗(2)
|
||||
*/
|
||||
void initialize(int mode);
|
||||
/**
|
||||
* @brief login 用户登录(用户登录时调用)
|
||||
*/
|
||||
void login();
|
||||
/**
|
||||
* @brief logout 用户退出(用户退出时调用)
|
||||
*/
|
||||
void logout();
|
||||
/**
|
||||
* @brief switchFaultRecallState 事故追忆切换
|
||||
* @param bFaultRecallState true-事故追忆 false-非事故追忆
|
||||
*/
|
||||
void switchFaultRecallState(bool bFaultRecallState);
|
||||
/**
|
||||
* @brief setAudioVolumeEnable 音量使能(仅设置一次即可)
|
||||
*/
|
||||
void setVolumeEnable(bool bEnable);
|
||||
/**
|
||||
* @brief setColumnWidth 设置列宽
|
||||
* @param column 列
|
||||
* @param width 宽
|
||||
*/
|
||||
void setColumnWidth(const int &column, const int &width);
|
||||
/**
|
||||
* @brief setColumnAlign 设置列对其方式
|
||||
* @param column 列
|
||||
* @param alignFlag 1-AlignLeft; 2-AlignRight; other-AlignHCenter
|
||||
*/
|
||||
void setColumnAlign(const int &column, const int &alignFlag);
|
||||
/**
|
||||
* @brief setEnableTrend 设置是否显示趋势图标 (程序默认显示)
|
||||
* @param isNeed true-显示 false-不显示
|
||||
*/
|
||||
void setEnableTrend(bool isNeed =true);
|
||||
/**
|
||||
* @brief setEnableVideo 设置是否显示视频图标 (程序默认显示)
|
||||
* @param isNeed true-显示 false-不显示
|
||||
*/
|
||||
void setEnableVideo(bool isNeed =true);
|
||||
/**
|
||||
* @brief setEnableWave 设置是否显示录波图标(程序默认显示)
|
||||
* @param isNeed true-显示 false-不显示
|
||||
*/
|
||||
void setEnableWave(bool isNeed = true);
|
||||
/**
|
||||
* @brief setEnableLevel 设置是否显示等级图标 (程序默认不显示)
|
||||
* @param isNeed true-显示 false-不显示
|
||||
*/
|
||||
void setEnableLevel(bool isNeed =true);
|
||||
/**
|
||||
* @brief getDevAlmInfo 获取设备告警信息
|
||||
* @param device 设备
|
||||
* @return QString 格式为: 告警等级_告警数量 ex:1_2 含义为 告警等级为1的告警数为2
|
||||
*/
|
||||
QStringList getDevAlmInfo(const QString device);
|
||||
/**
|
||||
* @brief getDevGroupAlmInfo 获取设备组下每个告警等级的设备数量
|
||||
* @param deviceGroup 设备组
|
||||
* @return QString 格式为: 告警等级_设备数量 ex:1_23 含义为 告警等级为1的设备数量为23
|
||||
*/
|
||||
QStringList getDevGroupAlmInfo(const QString deviceGroup);
|
||||
/**
|
||||
* @brief getLocAlmInfo 获取车站告警数量(优先级分组)
|
||||
* @return QString 格式为: 车站id_告警等级_告警数量 ex:1_1_23 含义为 车站1告警等级为1的告警数量为23
|
||||
*/
|
||||
QStringList getLocAlmInfo();
|
||||
/**
|
||||
* @brief getLocNotConfirmAlmCount 获取位置的未确认告警条数
|
||||
* @param loc 位置id
|
||||
* @return 未确认告警条数
|
||||
*/
|
||||
int getLocNotConfirmAlmCount(int loc);
|
||||
/**
|
||||
* @brief getDevgNotConfirmAlmCount 获取设备组的未确认告警条数
|
||||
* @param devg 设备组
|
||||
* @return 未确认告警条数数
|
||||
*/
|
||||
int getDevgNotConfirmAlmCount(const QString & devg);
|
||||
/***************************************************************************/
|
||||
|
||||
/****************以下接口仅针对E_Alarm_Window模式[告警大窗]有效********************/
|
||||
/**
|
||||
* @brief setEnableAccidentReview 设置告警大窗右键是否显示事故追忆
|
||||
* @param isNeed isNeed true-显示 false-不显示 (程序默认显示)
|
||||
*/
|
||||
void setEnableAccidentReview(bool isNeed = true);
|
||||
/**
|
||||
* @brief setAccidentReviewPath 设置事故追忆画面选择对话框路径 相对于pic
|
||||
* @param path
|
||||
*/
|
||||
void setAccidentReviewPath(const QString& path);
|
||||
/**
|
||||
* @brief setShowAiAlarmView 设置第一次是否显示智能告警(根据是否启用智能告警,一般不需要调用)
|
||||
* @param show true-显示 false-不显示 (根据是否启用智能告警) 不配置智能告警调用显示也无效
|
||||
*/
|
||||
void setShowAiAlarmView(bool show = true);
|
||||
/**
|
||||
* @brief setHiddenLocation 设置是否在告警大窗顶部隐藏车站过滤
|
||||
* @param hide true-隐藏 false-不隐藏(程序默认不隐藏)
|
||||
*/
|
||||
void setHiddenLocation(bool hide);
|
||||
/**
|
||||
* @brief setHiddenTime 设置是否在告警大窗顶部隐藏时间过滤
|
||||
* @param hide true-隐藏 false-不隐藏(程序默认不隐藏)
|
||||
*/
|
||||
void setHiddenTime(bool hide);
|
||||
/**
|
||||
* @brief setHiddenStatus 设置是否在告警大窗顶部隐藏状态过滤
|
||||
* @param hide true-隐藏 false-不隐藏(程序默认不隐藏)
|
||||
*/
|
||||
void setHiddenStatus(bool hide);
|
||||
/**
|
||||
* @brief setHiddenPriority 设置是否在告警大窗顶部隐藏优先级过滤
|
||||
* @param hide true-隐藏 false-不隐藏(程序默认不隐藏)
|
||||
*/
|
||||
void setHiddenPriority(bool hide);
|
||||
/**
|
||||
* @brief setHiddenCheckBox 设置是否在告警大窗顶部隐藏智能告警勾选框
|
||||
* @param hide true-隐藏 false-不隐藏(程序默认不隐藏)
|
||||
*/
|
||||
void setHiddenCheckBox(bool hide);
|
||||
/**
|
||||
* @brief setHiddenSetConfig 设置是否隐藏设置按钮
|
||||
* @param hide true-隐藏 false-不隐藏(程序默认不隐藏)
|
||||
*/
|
||||
void setHiddenSetConfig(bool hide);
|
||||
/**
|
||||
* @brief setHiddenCloseButton 设置是否隐藏关闭按钮
|
||||
* @param hide true-隐藏 false-不隐藏(程序默认不隐藏)
|
||||
*/
|
||||
void setHiddenCloseButton(bool hide);
|
||||
|
||||
/**
|
||||
* @brief setHiddenInhiAlarmButton 设置是否隐藏禁止告警按钮
|
||||
* @param hide true-隐藏 false-不隐藏(程序默认隐藏)
|
||||
*/
|
||||
void setHiddenInhiAlarmButton(bool hide);
|
||||
|
||||
/**
|
||||
* @brief setHiddenSelectButton 设置是否隐藏全选,全不选按钮
|
||||
* @param hide true-隐藏 false-不隐藏(程序默认隐藏)
|
||||
*/
|
||||
void setHiddenSelectButton(bool hide);
|
||||
|
||||
/**
|
||||
* @brief setFormColumnVisible 设置列是否显示
|
||||
* @param column 列
|
||||
* @param visible true-显示 false-不显示
|
||||
*/
|
||||
void setFormColumnVisible(const int &column, const bool &visible = true);
|
||||
/***************************************************************************/
|
||||
|
||||
/****************以下接口仅针对E_Alarm_Dock模式[底部告警栏]有效********************/
|
||||
/**
|
||||
* @brief confirmFirstAlarm 确认第一条告警
|
||||
* @param index 确认第几条(最大值为2)
|
||||
*/
|
||||
void confirmFirstAlarm(int index= 0);
|
||||
/**
|
||||
* @brief setDockRowHeight 设置行高
|
||||
* @param height 行高
|
||||
*/
|
||||
void setDockRowHeight(const int &height);
|
||||
/**
|
||||
* @brief setDockColumnVisible 设置列是否显示
|
||||
* @param column 列
|
||||
* @param visbile true-显示 false-不显示
|
||||
*/
|
||||
void setDockColumnVisible(const int &column, const bool &visbile = true);
|
||||
/**
|
||||
* @brief confirmAllPermAlarm 确认当前有权限的所有告警
|
||||
* @param tips true-确认后提示确认总数 false-确认后不需要提示确认总数
|
||||
* @return 确认总数
|
||||
*/
|
||||
int confirmAllPermAlarm(bool tips = true);
|
||||
/***************************************************************************/
|
||||
|
||||
/****************以下接口仅针对E_Alarm_Pop模式[设备对话框]有效********************/
|
||||
/**
|
||||
* @brief setDevice 设置设备显示(已无效,保留只为兼容)
|
||||
* @param device 设备
|
||||
*/
|
||||
void setDevice(const QString &device);
|
||||
|
||||
|
||||
/**
|
||||
* @brief setDeviceGroup 设置设备组显示
|
||||
* @param deviceGroup 设备组
|
||||
*/
|
||||
void setDeviceGroup(const QString &deviceGroup);
|
||||
|
||||
/**
|
||||
* @brief setPriorityFilter 设置优先级
|
||||
* @param deviceGroup 优先级
|
||||
*/
|
||||
void setPriorityFilter(int PriorityFilter);
|
||||
|
||||
/**
|
||||
* @brief setPointTag 设置点过滤(已无效,保留只为兼容)
|
||||
* @param pointList 点集合
|
||||
*/
|
||||
void setPointTag(const QString &pointList);
|
||||
/**
|
||||
* @brief setColumnVisible 设置列是否显示
|
||||
* @param column 列
|
||||
* @param visible true-显示 false-不显示
|
||||
*/
|
||||
void setColumnVisible(const int &column, const bool &visible);
|
||||
/**
|
||||
* @brief currentSelectCount 获取选中的告警条数
|
||||
* @return 告警条数
|
||||
*/
|
||||
int currentSelectCount();
|
||||
/**
|
||||
* @brief confirmCurrentAlarm 确认当前告警
|
||||
*/
|
||||
void confirmCurrentAlarm();
|
||||
/**
|
||||
* @brief confirmAllAlarm 确认所有告警
|
||||
*/
|
||||
void confirmAllAlarm();
|
||||
/**
|
||||
* @brief removeAllAlarm 删除所有告警
|
||||
*/
|
||||
void removeAllAlarm();
|
||||
|
||||
/***************************************************************************/
|
||||
/**
|
||||
* @brief recvAlarmNumChanged 告警数量变化
|
||||
* @param total 总数
|
||||
* @param unConfirm 未确认数
|
||||
*/
|
||||
void recvAlarmNumChanged(const int &total, const int &unConfirm);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief alarmNumChanged 告警数量变化
|
||||
*/
|
||||
void alarmNumChanged(const int &total, const int &unConfirm); //脚本更新数量
|
||||
/**
|
||||
* @brief alarmPush 告警推图
|
||||
*/
|
||||
void alarmPush(const QString &info);
|
||||
/**
|
||||
* @brief alarmPushClear 清空告警推图
|
||||
*/
|
||||
void alarmPushClear();
|
||||
/**
|
||||
* @brief alarmDockDoubleClicked 告警窗[Dock] 双击信号
|
||||
*/
|
||||
void alarmDockDoubleClicked();
|
||||
/**
|
||||
* @brief closeBtnClicked 告警窗[Window] 关闭按钮点击信号
|
||||
*/
|
||||
void closeBtnClicked();
|
||||
/**
|
||||
* @brief openVideoDialog 打开视频窗
|
||||
* @param domainId 域id
|
||||
* @param appId 应用id
|
||||
* @param tag 点标签
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
*/
|
||||
void openVideoDialog(int domainId,int appId,QString tag,quint64 startTime,quint64 endTime);
|
||||
/**
|
||||
* @brief openTrendDialog 打开趋势窗口
|
||||
* @param time_stamp 时间戳
|
||||
* @param tagList 标签集合
|
||||
*/
|
||||
void openTrendDialog(quint64 time_stamp,QStringList tagList);
|
||||
/**
|
||||
* @brief openAccidentReviewDialog 开始进行事故追忆
|
||||
* @param starTime 开始时间
|
||||
* @param keepTime 保持时间
|
||||
*/
|
||||
void openAccidentReviewDialog(quint64 starTime,quint64 keepTime,QString graph=QString());
|
||||
/**
|
||||
* @brief sigSwitchFaultRecallState 触发事故追忆(非hmi使用)
|
||||
* @param bFaultRecallState true-事故追忆 false-非事故追忆
|
||||
*/
|
||||
void sigSwitchFaultRecallState(bool bFaultRecallState);
|
||||
|
||||
void sigLogin();
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief slotUpdateAlarmView 更新视图
|
||||
*/
|
||||
void slotUpdateAlarmView();
|
||||
void slotUpdateAiAlarmView();
|
||||
/**
|
||||
* @brief slotUpdateAlarmOperateEnable 更新界面告警操作接口
|
||||
* @param bEnable
|
||||
*/
|
||||
void slotUpdateAlarmOperateEnable(const bool &bEnable);
|
||||
|
||||
void slotAllViewReload();
|
||||
|
||||
private:
|
||||
|
||||
void loadConfig();
|
||||
|
||||
void reset();
|
||||
|
||||
void updateAlarmOperatePerm();
|
||||
|
||||
private:
|
||||
E_Alarm_Mode m_mode;
|
||||
bool m_bIsEditMode;
|
||||
CAlarmForm * m_alarmForm;
|
||||
CAlarmWidget * m_alarmWidget;
|
||||
CAlarmView * m_alarmView;
|
||||
CAlarmItemModel * m_pModel;
|
||||
CAiAlarmTreeModel * m_pTreeModel;
|
||||
int m_currentUsrId{};
|
||||
std::string m_currentNodeName;
|
||||
std::vector <int> m_vecRegionOptId; //告警操作权限责任区
|
||||
std::vector <int> m_vecLocationOptId;//告警操作权限车站
|
||||
|
||||
std::vector <int> m_vecRegionDelId; //告警删除权限责任区
|
||||
std::vector <int> m_vecLocationDelId;//告警删除权限车站
|
||||
|
||||
//static int m_number;
|
||||
static QThread * m_pDataCollectThread;
|
||||
static QThread * m_pMediaPlayerThread;
|
||||
bool m_enableAi;
|
||||
};
|
||||
|
||||
#endif // CALARMPLUGIN_H
|
||||
@ -0,0 +1,29 @@
|
||||
#include <QWidget>
|
||||
#include "CAlarmPluginWidget.h"
|
||||
#include "CAlarmPlugin.h"
|
||||
#include "pub_logger_api/logger.h"
|
||||
|
||||
CAlarmPluginWidget::CAlarmPluginWidget(QObject *parent): QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CAlarmPluginWidget::~CAlarmPluginWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CAlarmPluginWidget::createWidget(QWidget *parent, bool editMode, QWidget **widget, IPluginWidget **alarmWidget, QVector<void *> ptrVec)
|
||||
{
|
||||
Q_UNUSED(ptrVec)
|
||||
CAlarmPlugin *pWidget = new CAlarmPlugin(parent, editMode);
|
||||
pWidget->initialize((int)E_Alarm_Dock);
|
||||
*widget = (QWidget *)pWidget;
|
||||
*alarmWidget = (IPluginWidget *)pWidget;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CAlarmPluginWidget::release()
|
||||
{
|
||||
|
||||
}
|
||||
22
product/src/gui/plugin/AlarmWidget_pad/CAlarmPluginWidget.h
Normal file
22
product/src/gui/plugin/AlarmWidget_pad/CAlarmPluginWidget.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef CALARMPLUGINWIDGET_H
|
||||
#define CALARMPLUGINWIDGET_H
|
||||
|
||||
#include <QObject>
|
||||
#include "GraphShape/CPluginWidget.h" //< ISCS6000_HOME/platform/src/include/gui/GraphShape
|
||||
|
||||
class CAlarmPluginWidget : public QObject, public CPluginWidgetInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID HMI_WidgetPlugin_IID)
|
||||
Q_INTERFACES(CPluginWidgetInterface)
|
||||
|
||||
public:
|
||||
CAlarmPluginWidget(QObject *parent = 0);
|
||||
~CAlarmPluginWidget();
|
||||
|
||||
bool createWidget(QWidget *parent, bool editMode, QWidget **widget, IPluginWidget **alarmWidget, QVector<void *> ptrVec);
|
||||
void release();
|
||||
};
|
||||
|
||||
#endif //CALARMPLUGINWIDGET_H
|
||||
|
||||
429
product/src/gui/plugin/AlarmWidget_pad/CAlarmSetDlg.cpp
Normal file
429
product/src/gui/plugin/AlarmWidget_pad/CAlarmSetDlg.cpp
Normal file
@ -0,0 +1,429 @@
|
||||
#include "CAlarmSetDlg.h"
|
||||
#include "ui_CAlarmSetDlg.h"
|
||||
#include <QDomDocument>
|
||||
#include "pub_utility_api/FileUtil.h"
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QGroupBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QColorDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QXmlStreamWriter>
|
||||
#include "CAlarmColorWidget.h"
|
||||
#include <QDir>
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include "pub_utility_api/FileStyle.h"
|
||||
#include <QListView>
|
||||
#include "CAlarmCommon.h"
|
||||
|
||||
CAlarmSetDlg::CAlarmSetDlg(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CAlarmSetDlg),
|
||||
m_pTextToSpeech(Q_NULLPTR)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QString qss = QString();
|
||||
std::string strFullPath = iot_public::CFileStyle::getPathOfStyleFile("public.qss") ;
|
||||
QFile qssfile1(QString::fromStdString(strFullPath));
|
||||
qssfile1.open(QFile::ReadOnly);
|
||||
if (qssfile1.isOpen())
|
||||
{
|
||||
qss += QLatin1String(qssfile1.readAll());
|
||||
qssfile1.close();
|
||||
}
|
||||
strFullPath = iot_public::CFileStyle::getPathOfStyleFile("alarm.qss") ;
|
||||
QFile qssfile2(QString::fromStdString(strFullPath));
|
||||
qssfile2.open(QFile::ReadOnly);
|
||||
if (qssfile2.isOpen())
|
||||
{
|
||||
qss += QLatin1String(qssfile2.readAll());
|
||||
qssfile2.close();
|
||||
}
|
||||
if(!qss.isEmpty())
|
||||
{
|
||||
setStyleSheet(qss);
|
||||
}
|
||||
init();
|
||||
ui->label->installEventFilter(this);
|
||||
ui->label_2->installEventFilter(this);
|
||||
ui->label_7->installEventFilter(this);
|
||||
connect(ui->pushButton_20,&QPushButton::clicked,this,&CAlarmSetDlg::save);
|
||||
connect(ui->pushButton_21,&QPushButton::clicked,this,&CAlarmSetDlg::cancle);
|
||||
connect(ui->radioButton,&QRadioButton::clicked,this,&CAlarmSetDlg::soundClicked);
|
||||
connect(ui->radioButton_2,&QRadioButton::clicked,this,&CAlarmSetDlg::voiceClicked);
|
||||
ui->alarmStyle->setView(new QListView());
|
||||
ui->engine->setView(new QListView());
|
||||
ui->language->setView(new QListView());
|
||||
ui->voiceName->setView(new QListView());
|
||||
}
|
||||
|
||||
CAlarmSetDlg::~CAlarmSetDlg()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CAlarmSetDlg::engineSelected(int index)
|
||||
{
|
||||
disconnect(ui->language, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CAlarmSetDlg::languageSelected);
|
||||
ui->language->clear();
|
||||
disconnect(ui->voiceName, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CAlarmSetDlg::voiceSelected);
|
||||
ui->voiceName->clear();
|
||||
|
||||
QString engineName = ui->engine->itemData(index).toString();
|
||||
if(m_pTextToSpeech != Q_NULLPTR)
|
||||
{
|
||||
delete m_pTextToSpeech;
|
||||
m_pTextToSpeech = Q_NULLPTR;
|
||||
}
|
||||
|
||||
m_engine = engineName;
|
||||
|
||||
if(m_engine == "default")
|
||||
{
|
||||
#ifdef OS_LINUX
|
||||
m_pTextToSpeech = Q_NULLPTR;
|
||||
return;
|
||||
#else
|
||||
m_pTextToSpeech = new QTextToSpeech(this);
|
||||
#endif
|
||||
}else
|
||||
{
|
||||
m_pTextToSpeech = new QTextToSpeech(m_engine,this);
|
||||
}
|
||||
|
||||
// disconnect(ui->language, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CAlarmSetDlg::languageSelected);
|
||||
// ui->language->clear();
|
||||
QVector<QLocale> locales = m_pTextToSpeech->availableLocales();
|
||||
QLocale current = m_pTextToSpeech->locale();
|
||||
|
||||
foreach (const QLocale &locale, locales) {
|
||||
QString name(QString("%1 (%2)")
|
||||
.arg(QLocale::languageToString(locale.language()))
|
||||
.arg(QLocale::countryToString(locale.country())));
|
||||
QVariant localeVariant(locale);
|
||||
ui->language->addItem(name, locale.name());
|
||||
if (locale.name() == m_language)
|
||||
current = locale;
|
||||
}
|
||||
|
||||
connect(ui->language, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CAlarmSetDlg::languageSelected);
|
||||
localeChanged(current);
|
||||
}
|
||||
|
||||
void CAlarmSetDlg::languageSelected(int language)
|
||||
{
|
||||
QLocale locale = ui->language->itemData(language).toLocale();
|
||||
m_pTextToSpeech->setLocale(locale);
|
||||
}
|
||||
|
||||
void CAlarmSetDlg::localeChanged(const QLocale &locale)
|
||||
{
|
||||
QVariant localeVariant(locale);
|
||||
ui->language->setCurrentIndex(ui->language->findData(QVariant(locale.name())));
|
||||
|
||||
disconnect(ui->voiceName, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CAlarmSetDlg::voiceSelected);
|
||||
ui->voiceName->clear();
|
||||
|
||||
m_voices = m_pTextToSpeech->availableVoices();
|
||||
QVoice currentVoice = m_pTextToSpeech->voice();
|
||||
foreach (const QVoice &voice, m_voices) {
|
||||
ui->voiceName->addItem(QString("%1 - %2 - %3").arg(voice.name())
|
||||
.arg(QVoice::genderName(voice.gender()))
|
||||
.arg(QVoice::ageName(voice.age())),voice.name());
|
||||
if (voice.name() == m_voiceName)
|
||||
ui->voiceName->setCurrentIndex(ui->voiceName->count() - 1);
|
||||
}
|
||||
connect(ui->voiceName, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CAlarmSetDlg::voiceSelected);
|
||||
}
|
||||
|
||||
void CAlarmSetDlg::voiceSelected(int index)
|
||||
{
|
||||
m_pTextToSpeech->setVoice(m_voices.at(index));
|
||||
}
|
||||
|
||||
void CAlarmSetDlg::init()
|
||||
{
|
||||
CAlarmSetMng::instance()->getColorMap(m_colorMap);
|
||||
CAlarmSetMng::instance()->getSelectInfo(m_selectIsEmpty,m_select_background_color,m_select_text_color);
|
||||
CAlarmSetMng::instance()->getEmptyInfo(m_emptyBackgroundColor,m_emptyTipColor,m_emptyTip);
|
||||
CAlarmSetMng::instance()->getActAndNum(m_act,m_num,m_style);
|
||||
CAlarmSetMng::instance()->getEngine(m_engine,m_language,m_voiceName);
|
||||
|
||||
ui->alarmStyle->addItem(tr("不报"), E_STYLE_NO_ALARM);
|
||||
ui->alarmStyle->addItem(tr("重复"), E_STYLE_REPEAT);
|
||||
ui->alarmStyle->addItem(tr("重复x次"), E_STYLE_REPEAT_X);
|
||||
initView();
|
||||
connect(ui->alarmStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(styleChanged(int)));
|
||||
emit ui->alarmStyle->currentIndexChanged(ui->alarmStyle->currentIndex());
|
||||
}
|
||||
|
||||
void CAlarmSetDlg::initView()
|
||||
{
|
||||
if(m_act == 0)
|
||||
{
|
||||
ui->radioButton->setChecked(true);
|
||||
ui->radioButton_2->setChecked(false);
|
||||
soundClicked(true);
|
||||
}else
|
||||
{
|
||||
ui->radioButton->setChecked(false);
|
||||
ui->radioButton_2->setChecked(true);
|
||||
voiceClicked(true);
|
||||
}
|
||||
int style = ui->alarmStyle->findData(m_style);
|
||||
if(style != -1)
|
||||
{
|
||||
ui->alarmStyle->setCurrentIndex(style);
|
||||
}
|
||||
ui->spinBox->setValue(m_num);
|
||||
QMap<int,CAlarmColorInfo>::iterator it= m_colorMap.begin();
|
||||
QVBoxLayout *vlayout = new QVBoxLayout(ui->widget_2);
|
||||
while (it!=m_colorMap.end()) {
|
||||
CAlarmColorWidget *form = new CAlarmColorWidget(&(it.value()),this);
|
||||
vlayout->addWidget(form);
|
||||
it++;
|
||||
}
|
||||
ui->widget_2->setContentsMargins(0,0,0,0);
|
||||
ui->widget_2->setLayout(vlayout);
|
||||
|
||||
ui->label->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(m_select_text_color.red()).arg(m_select_text_color.green()).arg(m_select_text_color.blue()));
|
||||
ui->label_2->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(m_emptyTipColor.red()).arg(m_emptyTipColor.green()).arg(m_emptyTipColor.blue()));
|
||||
ui->label_7->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(m_select_background_color.red()).arg(m_select_background_color.green()).arg(m_select_background_color.blue()));
|
||||
|
||||
ui->engine->addItem("default", QString("default"));
|
||||
QStringList engineList;
|
||||
#ifdef OS_LINUX
|
||||
//< TODO: centos选择语音告警,打开QtAV相关程序(IpcPluginWidget等)卡死。暂时隐藏。
|
||||
#else
|
||||
engineList = QTextToSpeech::availableEngines();
|
||||
if(engineList.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (QString engine, engineList)
|
||||
{
|
||||
ui->engine->addItem(engine, engine);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(m_engine.isEmpty() || !engineList.contains(m_engine))
|
||||
{
|
||||
m_engine = "default";
|
||||
}
|
||||
ui->engine->setCurrentText(m_engine);
|
||||
|
||||
int index= ui->engine->currentIndex();
|
||||
engineSelected(index);
|
||||
connect(ui->engine, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CAlarmSetDlg::engineSelected);
|
||||
|
||||
}
|
||||
|
||||
bool CAlarmSetDlg::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if(obj == ui->label)
|
||||
{
|
||||
if(event->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
if(mouseEvent->button() == Qt::LeftButton)
|
||||
{
|
||||
chooseColor(ui->label, &m_select_text_color);
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else if(obj == ui->label_2)
|
||||
{
|
||||
if(event->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
if(mouseEvent->button() == Qt::LeftButton)
|
||||
{
|
||||
chooseColor(ui->label_2, &m_emptyTipColor);
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else if(obj == ui->label_7)
|
||||
{
|
||||
if(event->type() == QMouseEvent::MouseButtonPress)
|
||||
{
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
if(mouseEvent->button() == Qt::LeftButton)
|
||||
{
|
||||
chooseColor(ui->label_7, &m_select_background_color);
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}else
|
||||
{
|
||||
return QWidget::eventFilter(obj,event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CAlarmSetDlg::chooseColor(QLabel *label, QColor *color)
|
||||
{
|
||||
QColor newColor=QColorDialog::getColor(*color,this);
|
||||
if(newColor.isValid()){
|
||||
*color=newColor;
|
||||
updateColorLabel(label,*color);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmSetDlg::updateColorLabel(QLabel *label, const QColor &color)
|
||||
{
|
||||
label->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(color.red()).arg(color.green()).arg(color.blue()));
|
||||
if(label == ui->label)
|
||||
{
|
||||
m_select_text_color = color;
|
||||
}else if(label == ui->label_2)
|
||||
{
|
||||
m_emptyTipColor = color;
|
||||
}else if(label == ui->label_7)
|
||||
{
|
||||
m_select_background_color = color;
|
||||
}
|
||||
}
|
||||
|
||||
bool CAlarmSetDlg::saveXML()
|
||||
{
|
||||
m_engine = ui->engine->currentData().toString();
|
||||
m_language = ui->language->currentData().toString();
|
||||
m_voiceName = ui->voiceName->currentData().toString();
|
||||
//写文本
|
||||
QString sFileName = QCoreApplication::applicationDirPath() + "/../../data/model/alarm_color_define.xml";
|
||||
QFile oFile( sFileName );
|
||||
if ( !oFile.exists() )
|
||||
{
|
||||
QMessageBox::critical( 0, "错误", QString("配置文件【%1】不存在,保存失败").arg(sFileName) );
|
||||
return false;
|
||||
}
|
||||
if ( !oFile.open(QIODevice::WriteOnly | QIODevice::Text) )
|
||||
{
|
||||
QMessageBox::critical( 0, "错误", QString("配置文件【%1】打开失败,保存失败").arg(sFileName) );
|
||||
return false;
|
||||
}
|
||||
m_num = ui->spinBox->value();
|
||||
QXmlStreamWriter writer(&oFile);
|
||||
writer.setAutoFormatting(true);
|
||||
writer.writeStartDocument();
|
||||
writer.writeStartElement("profile");
|
||||
|
||||
writer.writeStartElement("Flash");
|
||||
writer.writeAttribute( "alternate" ,QString::number(0));
|
||||
writer.writeEndElement();
|
||||
|
||||
QMap<int,CAlarmColorInfo>::iterator it= m_colorMap.begin();
|
||||
|
||||
while (it!=m_colorMap.end()) {
|
||||
writer.writeStartElement("Level");
|
||||
writer.writeAttribute( "priority" ,QString::number(it.key()));
|
||||
writer.writeAttribute( "background_color" ,"transparent");
|
||||
writer.writeAttribute( "alternating_color" ,it.value().alternating_color.name());
|
||||
writer.writeAttribute( "confirm_color" ,"transparent");
|
||||
writer.writeAttribute( "active_text_color" ,it.value().active_text_color.name());
|
||||
writer.writeAttribute( "resume_text_color" ,it.value().resume_text_color.name());
|
||||
writer.writeAttribute( "confirm_text_color" ,it.value().confirm_text_color.name());
|
||||
writer.writeAttribute( "icon" ,it.value().icon);
|
||||
writer.writeEndElement();
|
||||
it++;
|
||||
}
|
||||
writer.writeStartElement("Select");
|
||||
writer.writeAttribute( "background_color" ,m_select_background_color.name());
|
||||
writer.writeAttribute( "text_color" ,m_select_text_color.name());
|
||||
writer.writeEndElement();
|
||||
|
||||
writer.writeStartElement("NoItem");
|
||||
writer.writeAttribute( "background_color" ,"transparent");
|
||||
writer.writeAttribute( "tips_color" ,m_emptyTipColor.name());
|
||||
writer.writeAttribute( "tips" ,m_emptyTip);
|
||||
writer.writeEndElement();
|
||||
|
||||
writer.writeStartElement("Alarm");
|
||||
writer.writeAttribute( "act" ,QString::number(m_act));
|
||||
writer.writeAttribute("actDesc","0-声音告警 1-语音告警");
|
||||
writer.writeAttribute( "num" ,QString::number(m_num));
|
||||
writer.writeAttribute("style",QString::number(m_style));
|
||||
writer.writeEndElement();
|
||||
|
||||
writer.writeStartElement("VoiceEngine");
|
||||
writer.writeAttribute( "engine" ,m_engine);
|
||||
writer.writeAttribute( "language" ,m_language);
|
||||
writer.writeAttribute( "voice_name" ,m_voiceName);
|
||||
writer.writeEndElement();
|
||||
writer.writeEndElement();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CAlarmSetDlg::soundClicked(bool checked)
|
||||
{
|
||||
if(checked)
|
||||
{
|
||||
m_act = 0;
|
||||
}
|
||||
ui->engine->setEnabled(!checked);
|
||||
ui->language->setEnabled(!checked);
|
||||
ui->voiceName->setEnabled(!checked);
|
||||
}
|
||||
|
||||
void CAlarmSetDlg::voiceClicked(bool checked)
|
||||
{
|
||||
if(checked)
|
||||
{
|
||||
m_act = 1;
|
||||
}
|
||||
ui->engine->setEnabled(checked);
|
||||
ui->language->setEnabled(checked);
|
||||
ui->voiceName->setEnabled(checked);
|
||||
}
|
||||
|
||||
|
||||
void CAlarmSetDlg::save()
|
||||
{
|
||||
if(saveXML())
|
||||
{
|
||||
CAlarmSetMng::instance()->setColorMap(m_colorMap);
|
||||
m_selectIsEmpty = false;
|
||||
CAlarmSetMng::instance()->setSelectInfo(m_selectIsEmpty,m_select_background_color,m_select_text_color);
|
||||
CAlarmSetMng::instance()->setEmptyInfo(m_emptyBackgroundColor,m_emptyTipColor,m_emptyTip);
|
||||
CAlarmSetMng::instance()->setActAndNum(m_act,m_num,m_style);
|
||||
CAlarmSetMng::instance()->setEngine(m_engine,m_language,m_voiceName);
|
||||
CAlarmSetMng::instance()->sigUpdateColor();
|
||||
accept();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmSetDlg::cancle()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
void CAlarmSetDlg::styleChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
m_style = ui->alarmStyle->currentData().toInt();
|
||||
if(E_STYLE_REPEAT_X == m_style)
|
||||
{
|
||||
ui->spinBox->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->spinBox->setEnabled(false);
|
||||
}
|
||||
}
|
||||
72
product/src/gui/plugin/AlarmWidget_pad/CAlarmSetDlg.h
Normal file
72
product/src/gui/plugin/AlarmWidget_pad/CAlarmSetDlg.h
Normal file
@ -0,0 +1,72 @@
|
||||
#ifndef CALARMSETDLG_H
|
||||
#define CALARMSETDLG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "CAlarmColorInfo.h"
|
||||
#include "CAlarmSetMng.h"
|
||||
#include <QLabel>
|
||||
#include <QTextToSpeech>
|
||||
namespace Ui {
|
||||
class CAlarmSetDlg;
|
||||
}
|
||||
|
||||
class CAlarmSetDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CAlarmSetDlg(QWidget *parent = 0);
|
||||
~CAlarmSetDlg();
|
||||
|
||||
public slots:
|
||||
void engineSelected(int index);
|
||||
|
||||
void languageSelected(int language);
|
||||
void localeChanged(const QLocale &locale);
|
||||
void voiceSelected(int index);
|
||||
|
||||
private:
|
||||
void init();
|
||||
void initView();
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
private:
|
||||
void chooseColor(QLabel *label, QColor *color);
|
||||
void updateColorLabel(QLabel *label, const QColor &color);
|
||||
|
||||
bool saveXML();
|
||||
|
||||
private slots:
|
||||
|
||||
void soundClicked(bool checked);
|
||||
|
||||
void voiceClicked(bool checked);
|
||||
|
||||
void save();
|
||||
|
||||
void cancle();
|
||||
|
||||
void styleChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::CAlarmSetDlg *ui;
|
||||
QTextToSpeech *m_pTextToSpeech;
|
||||
QMap<int,CAlarmColorInfo> m_colorMap;
|
||||
QColor m_select_background_color,m_select_text_color; //选中告警背景色和文字颜色
|
||||
bool m_selectIsEmpty;
|
||||
|
||||
QColor m_emptyBackgroundColor,m_emptyTipColor;
|
||||
QString m_emptyTip;
|
||||
int m_act;
|
||||
int m_num;
|
||||
int m_style;
|
||||
|
||||
QString m_engine;
|
||||
QString m_language;
|
||||
QString m_voiceName;
|
||||
|
||||
QVector<QVoice> m_voices;
|
||||
};
|
||||
|
||||
#endif // CALARMSETDLG_H
|
||||
354
product/src/gui/plugin/AlarmWidget_pad/CAlarmSetDlg.ui
Normal file
354
product/src/gui/plugin/AlarmWidget_pad/CAlarmSetDlg.ui
Normal file
@ -0,0 +1,354 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAlarmSetDlg</class>
|
||||
<widget class="QDialog" name="CAlarmSetDlg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>699</width>
|
||||
<height>406</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>设置</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="set_frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>动作选择</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="radioButton">
|
||||
<property name="text">
|
||||
<string>声音告警</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="radioButton_2">
|
||||
<property name="text">
|
||||
<string>语音告警</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>告警方式</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>方式</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="alarmStyle">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>次数</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QSpinBox" name="spinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>优先级颜色选择</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_9">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>选中告警时,告警的文字颜色</p></body></html></string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>选中文字颜色</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>颜色</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_5">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>选中告警时,告警的背景颜色</p></body></html></string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>选中背景颜色</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>颜色</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_10">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>无告警时,告警小窗中&quot;当前无告警&quot;文字颜色</p></body></html></string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>无告警文字颜色</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="text">
|
||||
<string>颜色</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>语音引擎</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>引擎</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>语言</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>语音名称</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="language">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="voiceName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="engine">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>220</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="pushButton_20">
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="pushButton_21">
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
200
product/src/gui/plugin/AlarmWidget_pad/CAlarmSetMng.cpp
Normal file
200
product/src/gui/plugin/AlarmWidget_pad/CAlarmSetMng.cpp
Normal file
@ -0,0 +1,200 @@
|
||||
#include "CAlarmSetMng.h"
|
||||
#include <QDomDocument>
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include <QFile>
|
||||
#include "pub_utility_api/FileUtil.h"
|
||||
#include "CAlarmBaseData.h"
|
||||
|
||||
using namespace iot_public;
|
||||
using namespace std;
|
||||
|
||||
CAlarmSetMng *CAlarmSetMng::pInstance = NULL;
|
||||
|
||||
|
||||
CAlarmSetMng *CAlarmSetMng::instance()
|
||||
{
|
||||
if(pInstance == NULL)
|
||||
{
|
||||
pInstance = new CAlarmSetMng();
|
||||
}
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CAlarmSetMng::~CAlarmSetMng()
|
||||
{
|
||||
LOGDEBUG("CAlarmSetMng::~CAlarmSetMng()");
|
||||
}
|
||||
|
||||
bool CAlarmSetMng::isBindMediaPlayer()
|
||||
{
|
||||
return isSignalConnected(QMetaMethod::fromSignal(&CAlarmSetMng::sigLoadConfig));
|
||||
}
|
||||
|
||||
CAlarmSetMng::CAlarmSetMng()
|
||||
: QObject()
|
||||
{
|
||||
mutex = new QMutex();
|
||||
m_priorityOrderDescriptionMap = CAlarmBaseData::instance()->getPriorityOrderMap();
|
||||
loadXMLCfg();
|
||||
}
|
||||
|
||||
void CAlarmSetMng::loadXMLCfg()
|
||||
{
|
||||
m_colorMap.clear();
|
||||
QString filePath = QString::fromStdString(iot_public::CFileUtil::getCurModuleDir()) + QString("../../data/model/alarm_color_define.xml");
|
||||
QDomDocument document;
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!document.setContent(&file))
|
||||
{
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
|
||||
QDomElement element = document.documentElement();
|
||||
QDomNode node = element.firstChild();
|
||||
while(!node.isNull())
|
||||
{
|
||||
QDomElement attr = node.toElement();
|
||||
if(!attr.isNull())
|
||||
{
|
||||
if(QString("Level") == attr.tagName())
|
||||
{
|
||||
CAlarmColorInfo info;
|
||||
info.priority = attr.attribute("priority").toInt();
|
||||
info.background_color = QColor(attr.attribute("background_color"));
|
||||
info.alternating_color = QColor(attr.attribute("alternating_color"));
|
||||
info.confirm_color = QColor(attr.attribute("confirm_color"));
|
||||
|
||||
info.active_text_color = QColor(attr.attribute("active_text_color"));
|
||||
info.confirm_text_color = QColor(attr.attribute("confirm_text_color"));
|
||||
info.resume_text_color = QColor(attr.attribute("resume_text_color"));
|
||||
info.icon = attr.attribute("icon");
|
||||
m_colorMap[info.priority] = info;
|
||||
}
|
||||
else if(QString("Select") == attr.tagName())
|
||||
{
|
||||
m_select_background_color = QColor(attr.attribute("background_color"));
|
||||
if(attr.attribute("text_color").isEmpty())
|
||||
{
|
||||
m_selectIsEmpty = true;
|
||||
}else
|
||||
{
|
||||
m_selectIsEmpty = false;
|
||||
m_select_text_color = QColor(attr.attribute("text_color"));
|
||||
}
|
||||
}
|
||||
else if(QString("NoItem") == attr.tagName())
|
||||
{
|
||||
m_emptyBackgroundColor = QColor(attr.attribute("background_color"));
|
||||
m_emptyTipColor = QColor(attr.attribute("tips_color"));
|
||||
m_emptyTip = tr("当前无告警!");
|
||||
}else if(QString("Alarm") == attr.tagName())
|
||||
{
|
||||
m_act =attr.attribute("act").toInt();
|
||||
m_actDesc = attr.attribute("actDesc");
|
||||
m_num =attr.attribute("num").toInt();
|
||||
m_style = attr.attribute("style").toInt();
|
||||
}else if(QString("VoiceEngine") == attr.tagName())
|
||||
{
|
||||
m_engine = attr.attribute("engine");
|
||||
m_language = attr.attribute("language");
|
||||
m_voiceName = attr.attribute("voice_name");
|
||||
}
|
||||
}
|
||||
node = node.nextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmSetMng::destory()
|
||||
{
|
||||
pInstance = NULL;
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
void CAlarmSetMng::getPriorityInfo(QMap<int, QString> &priorityOrderDescriptionMap)
|
||||
{
|
||||
priorityOrderDescriptionMap.clear();
|
||||
priorityOrderDescriptionMap = m_priorityOrderDescriptionMap;
|
||||
}
|
||||
|
||||
void CAlarmSetMng::getColorMap(QMap<int, CAlarmColorInfo> &colorMap)
|
||||
{
|
||||
colorMap.clear();
|
||||
colorMap = m_colorMap;
|
||||
}
|
||||
|
||||
void CAlarmSetMng::getSelectInfo(bool &selectIsEmpty, QColor &select_background_color, QColor &select_text_color)
|
||||
{
|
||||
selectIsEmpty = m_selectIsEmpty;
|
||||
select_background_color = m_select_background_color;
|
||||
select_text_color = m_select_text_color;
|
||||
}
|
||||
|
||||
void CAlarmSetMng::getEmptyInfo(QColor &emptyBackgroundColor, QColor &emptyTipColor, QString &emptyTip)
|
||||
{
|
||||
emptyBackgroundColor = m_emptyBackgroundColor;
|
||||
emptyTipColor = m_emptyTipColor;
|
||||
emptyTip = m_emptyTip;
|
||||
}
|
||||
|
||||
void CAlarmSetMng::getActAndNum(int &act, int &num, int &style)
|
||||
{
|
||||
act = m_act;
|
||||
num = m_num;
|
||||
style = m_style;
|
||||
}
|
||||
|
||||
void CAlarmSetMng::getEngine(QString &engine, QString &language, QString &voiceName)
|
||||
{
|
||||
engine = m_engine;
|
||||
language = m_language;
|
||||
voiceName = m_voiceName;
|
||||
}
|
||||
|
||||
QString CAlarmSetMng::getPriorityDescByOrder(int order)
|
||||
{
|
||||
return m_priorityOrderDescriptionMap.value(order,tr("未知告警等级"));
|
||||
}
|
||||
|
||||
void CAlarmSetMng::setColorMap(const QMap<int, CAlarmColorInfo> &colorMap)
|
||||
{
|
||||
m_colorMap = colorMap;
|
||||
}
|
||||
|
||||
void CAlarmSetMng::setSelectInfo(const bool &selectIsEmpty,const QColor &select_background_color,const QColor &select_text_color)
|
||||
{
|
||||
m_selectIsEmpty = selectIsEmpty;
|
||||
m_select_background_color = select_background_color;
|
||||
m_select_text_color = select_text_color;
|
||||
}
|
||||
|
||||
void CAlarmSetMng::setEmptyInfo(const QColor &emptyBackgroundColor, const QColor &emptyTipColor, const QString &emptyTip)
|
||||
{
|
||||
m_emptyBackgroundColor= emptyBackgroundColor;
|
||||
m_emptyTipColor = emptyTipColor;
|
||||
m_emptyTip = emptyTip;
|
||||
}
|
||||
|
||||
void CAlarmSetMng::setActAndNum(const int &act, const int &num, const int &style)
|
||||
{
|
||||
m_act = act;
|
||||
m_num = num;
|
||||
m_style = style;
|
||||
}
|
||||
|
||||
void CAlarmSetMng::setEngine(const QString &engine, const QString &language, const QString &voiceName)
|
||||
{
|
||||
m_engine = engine;
|
||||
m_language = language;
|
||||
m_voiceName = voiceName;
|
||||
}
|
||||
|
||||
void CAlarmSetMng::sigUpdateColor()
|
||||
{
|
||||
emit sigLoadConfig();
|
||||
}
|
||||
90
product/src/gui/plugin/AlarmWidget_pad/CAlarmSetMng.h
Normal file
90
product/src/gui/plugin/AlarmWidget_pad/CAlarmSetMng.h
Normal file
@ -0,0 +1,90 @@
|
||||
#ifndef CALARMSETMNG_H
|
||||
#define CALARMSETMNG_H
|
||||
|
||||
#include <QObject>
|
||||
#include "dbms/rdb_api/CRdbAccess.h"
|
||||
#include <QMap>
|
||||
#include <QMutex>
|
||||
#include "CAlarmColorInfo.h"
|
||||
|
||||
class CAlarmSetMng : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static CAlarmSetMng * instance();
|
||||
~CAlarmSetMng();
|
||||
|
||||
void initialize();
|
||||
|
||||
bool isBindMediaPlayer();
|
||||
|
||||
signals:
|
||||
void sigLoadConfig();
|
||||
|
||||
private:
|
||||
|
||||
CAlarmSetMng();
|
||||
|
||||
void loadXMLCfg();
|
||||
|
||||
public slots:
|
||||
void destory();
|
||||
|
||||
void sigUpdateColor();
|
||||
|
||||
public:
|
||||
|
||||
void getPriorityInfo(QMap<int, QString> &priorityOrderDescriptionMap);
|
||||
|
||||
void getColorMap(QMap<int,CAlarmColorInfo> &colorMap);
|
||||
|
||||
void getSelectInfo(bool &selectIsEmpty,QColor &select_background_color,QColor &select_text_color);
|
||||
|
||||
void getEmptyInfo(QColor &emptyBackgroundColor, QColor &emptyTipColor, QString &emptyTip);
|
||||
|
||||
void getActAndNum(int &act,int &num, int &style);
|
||||
|
||||
void getEngine(QString &engine,QString &language,QString &voiceName);
|
||||
|
||||
QString getPriorityDescByOrder(int order);
|
||||
|
||||
void setColorMap(const QMap<int,CAlarmColorInfo> &colorMap);
|
||||
|
||||
void setSelectInfo(const bool &selectIsEmpty,const QColor &select_background_color,const QColor &select_text_color);
|
||||
|
||||
void setEmptyInfo(const QColor &emptyBackgroundColor, const QColor &emptyTipColor, const QString &emptyTip);
|
||||
|
||||
void setActAndNum(const int &act,const int &num,const int &style);
|
||||
|
||||
void setEngine(const QString &engine,const QString &language,const QString &voiceName);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
QMutex * mutex;
|
||||
static CAlarmSetMng * pInstance;
|
||||
|
||||
|
||||
iot_dbms::CRdbAccess * m_rtdbAccess;
|
||||
|
||||
QMap<int, QString> m_priorityOrderDescriptionMap;
|
||||
|
||||
QMap<int,CAlarmColorInfo> m_colorMap;
|
||||
QColor m_select_background_color,m_select_text_color; //选中告警背景色和文字颜色
|
||||
bool m_selectIsEmpty;
|
||||
|
||||
QColor m_emptyBackgroundColor,m_emptyTipColor;
|
||||
QString m_emptyTip;
|
||||
int m_act;
|
||||
int m_num;
|
||||
|
||||
QString m_actDesc;
|
||||
int m_style;
|
||||
|
||||
QString m_engine;
|
||||
QString m_language;
|
||||
QString m_voiceName;
|
||||
};
|
||||
|
||||
#endif // CALARMSETMNG_H
|
||||
118
product/src/gui/plugin/AlarmWidget_pad/CAlarmShiledDialog.cpp
Normal file
118
product/src/gui/plugin/AlarmWidget_pad/CAlarmShiledDialog.cpp
Normal file
@ -0,0 +1,118 @@
|
||||
#include "CAlarmShiledDialog.h"
|
||||
#include "ui_CAlarmShiledDialog.h"
|
||||
#include <QPluginLoader>
|
||||
#include <QDir>
|
||||
#include "pub_utility_api/FileUtil.h"
|
||||
#include "pub_utility_api/FileStyle.h"
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
CAlarmShiledDialog::CAlarmShiledDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CAlarmShiledDialog),
|
||||
m_pWidget(Q_NULLPTR),
|
||||
m_pPluginWidget(Q_NULLPTR)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QString qss = QString();
|
||||
std::string strFullPath = iot_public::CFileStyle::getPathOfStyleFile("public.qss") ;
|
||||
QFile qssfile1(QString::fromStdString(strFullPath));
|
||||
qssfile1.open(QFile::ReadOnly);
|
||||
if (qssfile1.isOpen())
|
||||
{
|
||||
qss += QLatin1String(qssfile1.readAll());
|
||||
qssfile1.close();
|
||||
}
|
||||
strFullPath = iot_public::CFileStyle::getPathOfStyleFile("alarm.qss") ;
|
||||
QFile qssfile2(QString::fromStdString(strFullPath));
|
||||
qssfile2.open(QFile::ReadOnly);
|
||||
if (qssfile2.isOpen())
|
||||
{
|
||||
qss += QLatin1String(qssfile2.readAll());
|
||||
qssfile2.close();
|
||||
}
|
||||
if(!qss.isEmpty())
|
||||
{
|
||||
setStyleSheet(qss);
|
||||
}
|
||||
m_pWidget = createCustomWidget("DataOptWidget");
|
||||
QGridLayout *layout = new QGridLayout(this);
|
||||
layout->addWidget(m_pWidget);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
ui->shield_frame->setLayout(layout);
|
||||
|
||||
}
|
||||
|
||||
CAlarmShiledDialog::~CAlarmShiledDialog()
|
||||
{
|
||||
if(m_pWidget)
|
||||
{
|
||||
delete m_pWidget;
|
||||
}
|
||||
m_pWidget = Q_NULLPTR;
|
||||
if(m_pPluginWidget)
|
||||
{
|
||||
|
||||
}
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QWidget *CAlarmShiledDialog::createCustomWidget(const QString &name)
|
||||
{
|
||||
QWidget *customWidget = NULL;
|
||||
QString fileName;
|
||||
QString path;
|
||||
|
||||
try
|
||||
{
|
||||
#ifdef OS_WINDOWS
|
||||
fileName = name;
|
||||
fileName += ".dll";
|
||||
#else
|
||||
if (name.contains(QRegExp("^lib")))
|
||||
{
|
||||
fileName = name;
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName += "lib";
|
||||
fileName += name;
|
||||
}
|
||||
fileName += ".so";
|
||||
#endif
|
||||
std::string filePath = iot_public::CFileUtil::getPathOfBinFile(fileName.toStdString());
|
||||
path = QString::fromStdString(filePath);
|
||||
QPluginLoader loader(path);
|
||||
QObject *plugin = loader.instance();
|
||||
if (plugin)
|
||||
{
|
||||
CPluginWidgetInterface *plugInInterface = qobject_cast<CPluginWidgetInterface *>(plugin);
|
||||
if (plugInInterface)
|
||||
{
|
||||
QVector<void *> ptrVect/* = getScene()->getDataAccess()->getPtr()*/;
|
||||
void *d= NULL;
|
||||
ptrVect.push_back(d);
|
||||
|
||||
plugInInterface->createWidget(this, false, &customWidget,
|
||||
&m_pPluginWidget, ptrVect);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
if (!customWidget)
|
||||
{
|
||||
customWidget = new QPushButton(tr("未找到插件"), this);
|
||||
}
|
||||
|
||||
return customWidget;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
customWidget = new QPushButton(tr("装载异常"), this);
|
||||
return customWidget;
|
||||
}
|
||||
}
|
||||
28
product/src/gui/plugin/AlarmWidget_pad/CAlarmShiledDialog.h
Normal file
28
product/src/gui/plugin/AlarmWidget_pad/CAlarmShiledDialog.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef CALARMSHILEDDIALOG_H
|
||||
#define CALARMSHILEDDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "../AlarmShieldWidget/CAlarmShield.h"
|
||||
#include "GraphShape/CPluginWidget.h"
|
||||
namespace Ui {
|
||||
class CAlarmShiledDialog;
|
||||
}
|
||||
|
||||
class CAlarmShiledDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CAlarmShiledDialog(QWidget *parent = nullptr);
|
||||
~CAlarmShiledDialog();
|
||||
|
||||
private:
|
||||
QWidget *createCustomWidget(const QString &name);
|
||||
private:
|
||||
Ui::CAlarmShiledDialog *ui;
|
||||
|
||||
QWidget *m_pWidget ;
|
||||
IPluginWidget *m_pPluginWidget;
|
||||
};
|
||||
|
||||
#endif // CALARMSHILEDDIALOG_H
|
||||
49
product/src/gui/plugin/AlarmWidget_pad/CAlarmShiledDialog.ui
Normal file
49
product/src/gui/plugin/AlarmWidget_pad/CAlarmShiledDialog.ui
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAlarmShiledDialog</class>
|
||||
<widget class="QDialog" name="CAlarmShiledDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1261</width>
|
||||
<height>542</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>禁止告警</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="shield_frame">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
134
product/src/gui/plugin/AlarmWidget_pad/CAlarmTaskMngDlg.cpp
Normal file
134
product/src/gui/plugin/AlarmWidget_pad/CAlarmTaskMngDlg.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
#include "CAlarmTaskMngDlg.h"
|
||||
#include "ui_CAlarmTaskMngDlg.h"
|
||||
#include <QMessageBox>
|
||||
#include <CAlarmMsgInfo.h>
|
||||
#include <pub_logger_api/logger.h>
|
||||
|
||||
|
||||
const int viewTaskHeight = 500;
|
||||
const int viewTaskWidth = 540;
|
||||
|
||||
CAlarmTaskMngDlg::CAlarmTaskMngDlg(AlarmMsgPtr info, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CAlarmTaskMngDlg),
|
||||
m_info(info)
|
||||
{
|
||||
setWindowFlags (windowFlags () & (~Qt::WindowContextHelpButtonHint));
|
||||
ui->setupUi(this);
|
||||
initUi();
|
||||
}
|
||||
|
||||
CAlarmTaskMngDlg::~CAlarmTaskMngDlg()
|
||||
{
|
||||
delete ui;
|
||||
delete m_view;
|
||||
}
|
||||
|
||||
void CAlarmTaskMngDlg::initUi()
|
||||
{
|
||||
this->resize(this->width(),ui->label->height());
|
||||
ui->btnCreat->setHidden(true);
|
||||
ui->btnViewProp->setHidden(true);
|
||||
ui->btnViewTsk->setHidden(true);
|
||||
ui->widget->setHidden(true);
|
||||
m_view = new QWebEngineView(this);
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
ui->widget->setLayout(layout);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
layout->addWidget(m_view);
|
||||
|
||||
if(!m_idongSrvApi.isValid())
|
||||
{
|
||||
QMessageBox::information(this,tr("提醒"),tr("艾动接口初始化失败"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string templateUUid;
|
||||
if(!m_idongSrvApi.getTaskTemplate(m_info->key_id_tag.toStdString(),templateUUid))
|
||||
{
|
||||
ui->labelTskGrpSts->setText(tr("未关联作业组,请先关联作业组"));
|
||||
ui->btnCreat->setHidden(true);
|
||||
return;
|
||||
}
|
||||
showTaskGrpStatus();
|
||||
}
|
||||
|
||||
void CAlarmTaskMngDlg::showTaskGrpStatus()
|
||||
{
|
||||
int status;
|
||||
if(!m_idongSrvApi.getTaskGrpStatus(m_info->uuid_base64.toStdString(),status))
|
||||
{
|
||||
LOGERROR("cannot get task group status");
|
||||
ui->labelTskGrpSts->setText("未能获取到作业组状态信息,请先创建作业组");
|
||||
ui->btnCreat->setHidden(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if(status >= 2)
|
||||
{
|
||||
ui->btnViewTsk->setHidden(false);
|
||||
}
|
||||
switch (status) {
|
||||
case 2:
|
||||
ui->labelTskGrpSts->setText("已发布");
|
||||
break;
|
||||
case 3:
|
||||
ui->labelTskGrpSts->setText("已创建");
|
||||
break;
|
||||
case 4:
|
||||
ui->labelTskGrpSts->setText("已执行");
|
||||
break;
|
||||
case 5:
|
||||
ui->labelTskGrpSts->setText("已延期");
|
||||
break;
|
||||
case 6:
|
||||
ui->labelTskGrpSts->setText("已过期");
|
||||
break;
|
||||
case 7:
|
||||
ui->labelTskGrpSts->setText("已超时");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CAlarmTaskMngDlg::on_btnCreat_clicked()
|
||||
{
|
||||
std::string templateUUid;
|
||||
if(!m_idongSrvApi.getTaskTemplate(m_info->key_id_tag.toStdString(),templateUUid))
|
||||
{
|
||||
ui->labelTskGrpSts->setText(tr("未关联作业组,请先关联作业组"));
|
||||
return;
|
||||
}
|
||||
if(m_idongSrvApi.createTaskGroupEx(m_info->uuid_base64.toStdString(),templateUUid,(m_info->content + "__巡检").toStdString()))
|
||||
{
|
||||
QMessageBox::information(this,tr("提醒"),tr("创建作业组成功"));
|
||||
|
||||
/**
|
||||
展示成功画面,状态显示,那七个状态,然后,显示展示按钮。
|
||||
**/
|
||||
showTaskGrpStatus();
|
||||
ui->btnCreat->setHidden(true);
|
||||
}else
|
||||
{
|
||||
QMessageBox::information(this,tr("提醒"),tr("创建作业组失败"));
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmTaskMngDlg::on_btnViewTsk_clicked()
|
||||
{
|
||||
this->resize(viewTaskWidth,viewTaskHeight);
|
||||
QString urlDst;
|
||||
if(!m_idongSrvApi.getTaskGrpLink(m_info->uuid_base64.toStdString(),urlDst))
|
||||
{
|
||||
QMessageBox::information(this,tr("提醒"),tr("获取作业组信息失败"));
|
||||
return;
|
||||
}
|
||||
LOGINFO("作业组链接:%s",QUrl::fromPercentEncoding(urlDst.toStdString().c_str()).toStdString().c_str());
|
||||
m_view->load( urlDst );
|
||||
ui->widget->setHidden(false);
|
||||
ui->btnViewTsk->setHidden(true);
|
||||
|
||||
}
|
||||
37
product/src/gui/plugin/AlarmWidget_pad/CAlarmTaskMngDlg.h
Normal file
37
product/src/gui/plugin/AlarmWidget_pad/CAlarmTaskMngDlg.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef CALARMTASKMNGDLG_H
|
||||
#define CALARMTASKMNGDLG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "CAlarmCommon.h"
|
||||
#include "application/idong_srv_api/CIDongSrvApi.h"
|
||||
#include <QWebEngineView>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class CAlarmTaskMngDlg;
|
||||
}
|
||||
|
||||
class CAlarmTaskMngDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CAlarmTaskMngDlg(AlarmMsgPtr info,QWidget *parent = 0);
|
||||
~CAlarmTaskMngDlg();
|
||||
|
||||
private slots:
|
||||
void on_btnCreat_clicked();
|
||||
|
||||
void on_btnViewTsk_clicked();
|
||||
|
||||
private:
|
||||
void initUi();
|
||||
void showTaskGrpStatus();
|
||||
|
||||
Ui::CAlarmTaskMngDlg *ui;
|
||||
AlarmMsgPtr m_info;
|
||||
CIDongSrvApi m_idongSrvApi;
|
||||
QWebEngineView *m_view;
|
||||
};
|
||||
|
||||
#endif // CALARMTASKMNGDLG_H
|
||||
76
product/src/gui/plugin/AlarmWidget_pad/CAlarmTaskMngDlg.ui
Normal file
76
product/src/gui/plugin/AlarmWidget_pad/CAlarmTaskMngDlg.ui
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAlarmTaskMngDlg</class>
|
||||
<widget class="QDialog" name="CAlarmTaskMngDlg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>427</width>
|
||||
<height>211</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>工单管理</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>作业组状态:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelTskGrpSts">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>未创建</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnCreat">
|
||||
<property name="text">
|
||||
<string>创建作业组</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnViewTsk">
|
||||
<property name="text">
|
||||
<string>查看作业组</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnViewProp">
|
||||
<property name="text">
|
||||
<string>查看资产</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
50
product/src/gui/plugin/AlarmWidget_pad/CAlarmView.cpp
Normal file
50
product/src/gui/plugin/AlarmWidget_pad/CAlarmView.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include <QHeaderView>
|
||||
#include <QMouseEvent>
|
||||
#include "CAlarmView.h"
|
||||
#include <QScrollBar>
|
||||
|
||||
CAlarmView::CAlarmView(QWidget *parent)
|
||||
: QTableView(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CAlarmView::initialize()
|
||||
{
|
||||
setSortingEnabled(true);
|
||||
setAlternatingRowColors(true);
|
||||
//horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
|
||||
verticalHeader()->setSectionResizeMode(QHeaderView::Interactive);
|
||||
//horizontalHeader()->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
//horizontalHeader()->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
|
||||
//horizontalHeader()->setMaximumWidth(800);
|
||||
|
||||
// resizeColumnsToContents();
|
||||
// resizeRowsToContents();
|
||||
// for(int i=0;i<horizontalHeader()->count()-1;i++)
|
||||
// resizeColumnToContents(i);
|
||||
|
||||
horizontalHeader()->setStretchLastSection(true);
|
||||
|
||||
resizeColumnsToContents();
|
||||
resizeRowsToContents();
|
||||
//setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
//setHorizontalScrollMode(ScrollPerPixel);
|
||||
setAutoScroll(true);
|
||||
horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
void CAlarmView::setDefaultRowHeight(int height)
|
||||
{
|
||||
verticalHeader()->setDefaultSectionSize(height);
|
||||
}
|
||||
|
||||
|
||||
void CAlarmView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
emit alarmViewDoubleClicked();
|
||||
QTableView::mouseDoubleClickEvent(event);
|
||||
}
|
||||
26
product/src/gui/plugin/AlarmWidget_pad/CAlarmView.h
Normal file
26
product/src/gui/plugin/AlarmWidget_pad/CAlarmView.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef CALARMVIEW_H
|
||||
#define CALARMVIEW_H
|
||||
|
||||
#include <QTableView>
|
||||
|
||||
class CAlarmView : public QTableView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CAlarmView(QWidget *parent = Q_NULLPTR);
|
||||
|
||||
void initialize();
|
||||
|
||||
void setDefaultRowHeight(int height);
|
||||
signals:
|
||||
void alarmViewDoubleClicked();
|
||||
|
||||
void openVideo(int domainId,int appId,QString tag,quint64 startTime,quint64 endTime);
|
||||
|
||||
void openTrend(quint64 time_stamp,QStringList tagList);
|
||||
protected:
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
};
|
||||
|
||||
#endif // ALARMVIEW_H
|
||||
435
product/src/gui/plugin/AlarmWidget_pad/CAlarmWidget.cpp
Normal file
435
product/src/gui/plugin/AlarmWidget_pad/CAlarmWidget.cpp
Normal file
@ -0,0 +1,435 @@
|
||||
#include "CAlarmWidget.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QTableView>
|
||||
#include <QHeaderView>
|
||||
#include <QSoundEffect>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
#include <QMouseEvent>
|
||||
#include "CAlarmForm.h"
|
||||
#include "CAlarmView.h"
|
||||
#include "CAlarmMsgInfo.h"
|
||||
#include "CAlarmItemModel.h"
|
||||
#include "CAlarmDataCollect.h"
|
||||
#include "CAlarmDelegate.h"
|
||||
#include "perm_mng_api/PermMngApi.h"
|
||||
#include "public/pub_sysinfo_api/SysInfoApi.h"
|
||||
#include <QDebug>
|
||||
#include <QStandardItemModel>
|
||||
#include "pub_logger_api/logger.h"
|
||||
|
||||
CAlarmWidget::CAlarmWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
m_pView(Q_NULLPTR),
|
||||
m_pModel(Q_NULLPTR),
|
||||
m_delegate(Q_NULLPTR), m_userId(0),
|
||||
m_pConfirmButtonRow0(Q_NULLPTR),
|
||||
m_pConfirmButtonRow1(Q_NULLPTR),
|
||||
m_pConfirmButtonRow2(Q_NULLPTR)
|
||||
{
|
||||
//initialize();
|
||||
}
|
||||
|
||||
CAlarmWidget::~CAlarmWidget()
|
||||
{
|
||||
if(Q_NULLPTR != m_delegate)
|
||||
{
|
||||
delete m_delegate;
|
||||
}
|
||||
m_delegate = Q_NULLPTR;
|
||||
qDebug() << "~CAlarmWidget()";
|
||||
}
|
||||
|
||||
void CAlarmWidget::setAlarmModel(CAlarmItemModel *pModel)
|
||||
{
|
||||
if(!pModel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_pModel = pModel;
|
||||
m_pView->setModel(m_pModel);
|
||||
|
||||
if(!m_delegate)
|
||||
{
|
||||
m_delegate = new CAlarmDelegate(m_pModel, this);
|
||||
m_pView->setItemDelegate(m_delegate);
|
||||
connect(m_delegate,&CAlarmDelegate::openVideo,this,&CAlarmWidget::openVideo,Qt::QueuedConnection);
|
||||
connect(m_delegate,&CAlarmDelegate::openTrend,this,&CAlarmWidget::openTrend,Qt::QueuedConnection);
|
||||
connect(CAlarmSetMng::instance(),&CAlarmSetMng::sigLoadConfig,m_delegate,&CAlarmDelegate::slotLoadConfig,Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
connect(m_pConfirmButtonRow0, SIGNAL(clicked()), this, SLOT(slotConfirmRow0()));
|
||||
connect(m_pConfirmButtonRow1, SIGNAL(clicked()), this, SLOT(slotConfirmRow1()));
|
||||
connect(m_pConfirmButtonRow2, SIGNAL(clicked()), this, SLOT(slotConfirmRow2()));
|
||||
|
||||
|
||||
m_pView->setColumnHidden(0, false);
|
||||
m_pView->setColumnHidden(1, false);
|
||||
m_pView->setColumnHidden(2, false);
|
||||
m_pView->setColumnHidden(3, true);
|
||||
m_pView->setColumnHidden(4, true);
|
||||
m_pView->setColumnHidden(5, false);
|
||||
m_pView->setColumnHidden(6, false);
|
||||
m_pView->setColumnHidden(7, false);
|
||||
|
||||
|
||||
m_pView->setColumnWidth(0, 230);
|
||||
m_pView->setColumnWidth(1, 120);
|
||||
m_pView->setColumnWidth(2, 150);
|
||||
m_pView->setColumnWidth(5, 150);
|
||||
m_pView->setColumnWidth(6, 120);
|
||||
|
||||
updateRowHeight();
|
||||
}
|
||||
|
||||
void CAlarmWidget::setRowHeight(const int &height)
|
||||
{
|
||||
if(m_pView)
|
||||
{
|
||||
m_pView->setRowHeight(0, height);
|
||||
m_pView->setRowHeight(1, height);
|
||||
m_pView->setRowHeight(2, height);
|
||||
updateRowHeight();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmWidget::setDockColumnVisible(const int &column, const bool &visbile)
|
||||
{
|
||||
if(m_pView)
|
||||
{
|
||||
m_pView->setColumnHidden(column, !visbile);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmWidget::updateRowHeight()
|
||||
{
|
||||
int nHeight = m_pView->rowHeight(0);
|
||||
m_pConfirmButtonRow0->setMinimumHeight(nHeight);
|
||||
m_pConfirmButtonRow1->setMinimumHeight(nHeight);
|
||||
m_pConfirmButtonRow2->setMinimumHeight(nHeight);
|
||||
setFixedHeight(nHeight * 3 + 1);
|
||||
}
|
||||
|
||||
void CAlarmWidget::updateView()
|
||||
{
|
||||
if(m_pView != Q_NULLPTR)
|
||||
{
|
||||
m_pView->setShowGrid(m_pModel->getShowAlarmCount());
|
||||
m_pModel->updateAlternate();
|
||||
m_pView->viewport()->update();
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmWidget::setAlarmOperateEnable(const bool &bEnable)
|
||||
{
|
||||
m_pConfirmButtonRow0->setEnabled(bEnable);
|
||||
m_pConfirmButtonRow1->setEnabled(bEnable);
|
||||
m_pConfirmButtonRow2->setEnabled(bEnable);
|
||||
}
|
||||
|
||||
void CAlarmWidget::setColumnWidth(const int &column, const int &width)
|
||||
{
|
||||
if(m_pView != Q_NULLPTR)
|
||||
{
|
||||
m_pView->setColumnWidth(column, width);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmWidget::initialize()
|
||||
{
|
||||
QHBoxLayout * pLayout = new QHBoxLayout(this);
|
||||
pLayout->setMargin(0);
|
||||
setLayout(pLayout);
|
||||
|
||||
m_pView = new CAlarmView(this);
|
||||
m_pView->setAlternatingRowColors(true);
|
||||
m_pView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_pView->setSelectionMode(QAbstractItemView::NoSelection);
|
||||
m_pView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_pView->horizontalHeader()->setStretchLastSection(true);
|
||||
m_pView->horizontalHeader()->setVisible(false);
|
||||
|
||||
m_pView->verticalHeader()->setVisible(false);
|
||||
m_pView->setColumnWidth(0, 150);
|
||||
pLayout->addWidget(m_pView);
|
||||
QVBoxLayout * pConfirmBtnLayout = new QVBoxLayout();
|
||||
m_pConfirmButtonRow0 = new QPushButton(tr("确认"));
|
||||
m_pConfirmButtonRow1 = new QPushButton(tr("确认"));
|
||||
m_pConfirmButtonRow2 = new QPushButton(tr("确认"));
|
||||
int nHeight = 23;
|
||||
m_pConfirmButtonRow0->setMinimumHeight(nHeight);
|
||||
m_pConfirmButtonRow1->setMinimumHeight(nHeight);
|
||||
m_pConfirmButtonRow2->setMinimumHeight(nHeight);
|
||||
setMinimumHeight(nHeight * 3);
|
||||
|
||||
pConfirmBtnLayout->addWidget(m_pConfirmButtonRow0);
|
||||
pConfirmBtnLayout->addWidget(m_pConfirmButtonRow1);
|
||||
pConfirmBtnLayout->addWidget(m_pConfirmButtonRow2);
|
||||
|
||||
pConfirmBtnLayout->addStretch();
|
||||
pLayout->addLayout(pConfirmBtnLayout);
|
||||
layout()->setSpacing(0);
|
||||
|
||||
updateAlarmOperatePerm();
|
||||
|
||||
m_pConfirmButtonRow0->setVisible(false);
|
||||
m_pConfirmButtonRow1->setVisible(false);
|
||||
m_pConfirmButtonRow2->setVisible(false);
|
||||
connect(m_pView, &CAlarmView::alarmViewDoubleClicked, this, &CAlarmWidget::alarmWidgetDoubleClicked);
|
||||
}
|
||||
|
||||
void CAlarmWidget::initializeEdit()
|
||||
{
|
||||
QHBoxLayout * pLayout = new QHBoxLayout(this);
|
||||
pLayout->setMargin(0);
|
||||
setLayout(pLayout);
|
||||
//m_header << tr("时间") << tr("优先级") << tr("位置") << tr("责任区") << tr("告警类型") << tr("告警状态") << tr("确认状态") << tr("告警内容");
|
||||
QStandardItemModel *model = new QStandardItemModel();
|
||||
model->setItem(0,0,new QStandardItem("2020-01-01 12:59:59.999"));
|
||||
model->setItem(0,1,new QStandardItem("高"));
|
||||
model->setItem(0,2,new QStandardItem("XX位置"));
|
||||
model->setItem(0,3,new QStandardItem("-"));
|
||||
model->setItem(0,4,new QStandardItem("系统信息"));
|
||||
model->setItem(0,5,new QStandardItem("通道异常"));
|
||||
model->setItem(0,6,new QStandardItem("未确认"));
|
||||
model->setItem(0,7,new QStandardItem("通道:chanX,通道状态:通讯中断!"));
|
||||
model->item(0,0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
model->item(0,1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
model->item(0,2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
model->item(0,3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
model->item(0,4)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
model->item(0,5)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
model->item(0,6)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
model->item(0,7)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
m_pView = new CAlarmView(this);
|
||||
m_pView->setAlternatingRowColors(true);
|
||||
m_pView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_pView->setSelectionMode(QAbstractItemView::NoSelection);
|
||||
m_pView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_pView->horizontalHeader()->setStretchLastSection(true);
|
||||
m_pView->horizontalHeader()->setVisible(false);
|
||||
m_pView->verticalHeader()->setVisible(false);
|
||||
|
||||
//m_pView->setColumnWidth(0, 150);
|
||||
pLayout->addWidget(m_pView);
|
||||
QVBoxLayout * pConfirmBtnLayout = new QVBoxLayout();
|
||||
m_pConfirmButtonRow0 = new QPushButton(tr("确认"));
|
||||
m_pConfirmButtonRow1 = new QPushButton(tr("确认"));
|
||||
m_pConfirmButtonRow2 = new QPushButton(tr("确认"));
|
||||
int nHeight = 23;
|
||||
m_pConfirmButtonRow0->setMinimumHeight(nHeight);
|
||||
m_pConfirmButtonRow1->setMinimumHeight(nHeight);
|
||||
m_pConfirmButtonRow2->setMinimumHeight(nHeight);
|
||||
setMinimumHeight(nHeight * 3);
|
||||
|
||||
pConfirmBtnLayout->addWidget(m_pConfirmButtonRow0);
|
||||
pConfirmBtnLayout->addWidget(m_pConfirmButtonRow1);
|
||||
pConfirmBtnLayout->addWidget(m_pConfirmButtonRow2);
|
||||
|
||||
pConfirmBtnLayout->addStretch();
|
||||
pLayout->addLayout(pConfirmBtnLayout);
|
||||
layout()->setSpacing(0);
|
||||
|
||||
updateAlarmOperatePerm();
|
||||
|
||||
m_pConfirmButtonRow0->setVisible(false);
|
||||
m_pConfirmButtonRow1->setVisible(false);
|
||||
m_pConfirmButtonRow2->setVisible(false);
|
||||
|
||||
|
||||
m_pView->setModel(model);
|
||||
m_pView->setColumnHidden(0, false);
|
||||
m_pView->setColumnHidden(1, false);
|
||||
m_pView->setColumnHidden(2, false);
|
||||
m_pView->setColumnHidden(3, true);
|
||||
m_pView->setColumnHidden(4, true);
|
||||
m_pView->setColumnHidden(5, false);
|
||||
m_pView->setColumnHidden(6, false);
|
||||
m_pView->setColumnHidden(7, false);
|
||||
|
||||
|
||||
m_pView->setColumnWidth(0, 230);
|
||||
m_pView->setColumnWidth(1, 120);
|
||||
m_pView->setColumnWidth(2, 150);
|
||||
m_pView->setColumnWidth(5, 150);
|
||||
m_pView->setColumnWidth(6, 120);
|
||||
|
||||
m_pView->setRowHeight(0,50);
|
||||
|
||||
//connect(m_pView, &CAlarmView::alarmViewDoubleClicked, this, &CAlarmWidget::alarmWidgetDoubleClicked);
|
||||
}
|
||||
|
||||
void CAlarmWidget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
if(Q_NULLPTR != m_pConfirmButtonRow0)
|
||||
{
|
||||
delete m_pConfirmButtonRow0;
|
||||
m_pConfirmButtonRow0 = Q_NULLPTR;
|
||||
}
|
||||
if(Q_NULLPTR != m_pConfirmButtonRow1)
|
||||
{
|
||||
delete m_pConfirmButtonRow1;
|
||||
m_pConfirmButtonRow1 = Q_NULLPTR;
|
||||
}
|
||||
if(Q_NULLPTR != m_pConfirmButtonRow2)
|
||||
{
|
||||
delete m_pConfirmButtonRow2;
|
||||
m_pConfirmButtonRow2 = Q_NULLPTR;
|
||||
}
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
void CAlarmWidget::confirmAlarm(const int &row)
|
||||
{
|
||||
//构建告警确认package
|
||||
if(row >= m_pModel->getListShowAlarmInfo().count())
|
||||
{
|
||||
return;
|
||||
}
|
||||
AlarmMsgPtr info = m_pModel->getListShowAlarmInfo().at(row);
|
||||
|
||||
updateAlarmOperatePerm();
|
||||
if(!m_listLocationOptId.contains(info->location_id))
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("当前用户不具备该告警所在位置的操作权限!"));
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
if(!m_listRegionOptId.contains(info->region_id) && info->region_id != -1)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("当前用户不具备该告警所在责任区的操作权限!"));
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
iot_idl::SAlmCltCfmAlm * pkg = new iot_idl::SAlmCltCfmAlm();
|
||||
pkg->set_node_name(m_nodeName);
|
||||
pkg->set_user_id(m_userId);
|
||||
pkg->set_confirm_time(QDateTime::currentMSecsSinceEpoch());
|
||||
pkg->set_domain_id(info->domain_id);
|
||||
pkg->set_app_id(info->app_id);
|
||||
pkg->set_alm_type(info->alm_type);
|
||||
pkg->add_key_id_tag(info->key_id_tag.toStdString());
|
||||
pkg->add_time_stamp(info->time_stamp);
|
||||
pkg->add_uuid_base64(info->uuid_base64.toStdString());
|
||||
//请求确认
|
||||
CAlarmDataCollect::instance()->requestCfmAlm(*pkg);
|
||||
|
||||
delete pkg;
|
||||
}
|
||||
|
||||
void CAlarmWidget::setEnableTrend(bool isNeed)
|
||||
{
|
||||
if(m_delegate)
|
||||
{
|
||||
m_delegate->setEnableTrend(isNeed);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmWidget::setEnableVideo(bool isNeed)
|
||||
{
|
||||
if(m_delegate)
|
||||
{
|
||||
m_delegate->setEnableVideo(isNeed);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmWidget::setEnableWave(bool isNeed)
|
||||
{
|
||||
if(m_delegate)
|
||||
{
|
||||
m_delegate->setEnableWave(isNeed);
|
||||
}
|
||||
}
|
||||
|
||||
void CAlarmWidget::setEnableLevel(bool isNeed)
|
||||
{
|
||||
if(m_delegate)
|
||||
{
|
||||
m_delegate->setEnableLevel(isNeed);
|
||||
}
|
||||
}
|
||||
|
||||
bool CAlarmWidget::updateAlarmOperatePerm()
|
||||
{
|
||||
iot_public::SNodeInfo stNodeInfo;
|
||||
iot_public::CSysInfoInterfacePtr spSysInfo;
|
||||
if (!iot_public::createSysInfoInstance(spSysInfo))
|
||||
{
|
||||
LOGERROR("创建系统信息访问库实例失败!");
|
||||
return false;
|
||||
}
|
||||
spSysInfo->getLocalNodeInfo(stNodeInfo);
|
||||
m_nodeName = stNodeInfo.strName;
|
||||
m_listLocationOptId.clear();
|
||||
m_listRegionOptId.clear();
|
||||
m_listLocationDelId.clear();
|
||||
m_listRegionDelId.clear();
|
||||
iot_service::CPermMngApiPtr permMngPtr = iot_service::getPermMngInstance("base");
|
||||
if(permMngPtr != NULL)
|
||||
{
|
||||
permMngPtr->PermDllInit();
|
||||
int nUserGrpId;
|
||||
int nLevel;
|
||||
int nLoginSec;
|
||||
std::string strInstanceName;
|
||||
if(0 != permMngPtr->CurUser(m_userId, nUserGrpId, nLevel, nLoginSec, strInstanceName))
|
||||
{
|
||||
m_userId = -1;
|
||||
LOGERROR("用户ID获取失败!");
|
||||
return false;
|
||||
}
|
||||
std::vector <int> vecRegionOptId;
|
||||
std::vector <int> vecLocationOptId;
|
||||
if(PERM_NORMAL == permMngPtr->GetSpeFunc(FUNC_SPE_ALARM_OPERATE, vecRegionOptId, vecLocationOptId))
|
||||
{
|
||||
std::vector <int>::iterator region = vecRegionOptId.begin();
|
||||
while (region != vecRegionOptId.end())
|
||||
{
|
||||
m_listRegionOptId.append(*region++);
|
||||
}
|
||||
|
||||
std::vector <int>::iterator location = vecLocationOptId.begin();
|
||||
while (location != vecLocationOptId.end())
|
||||
{
|
||||
m_listLocationOptId.append(*location++);
|
||||
}
|
||||
}
|
||||
std::vector <int> vecRegionDelId;
|
||||
std::vector <int> vecLocationDelId;
|
||||
if(PERM_NORMAL == permMngPtr->GetSpeFunc(FUNC_SPE_ALARM_DELETE, vecRegionDelId, vecLocationDelId))
|
||||
{
|
||||
std::vector <int>::iterator region = vecRegionDelId.begin();
|
||||
while (region != vecRegionDelId.end())
|
||||
{
|
||||
m_listRegionDelId.append(*region++);
|
||||
}
|
||||
|
||||
std::vector <int>::iterator location = vecLocationDelId.begin();
|
||||
while (location != vecLocationDelId.end())
|
||||
{
|
||||
m_listLocationDelId.append(*location++);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CAlarmWidget::slotConfirmRow0()
|
||||
{
|
||||
confirmAlarm(0);
|
||||
}
|
||||
|
||||
void CAlarmWidget::slotConfirmRow1()
|
||||
{
|
||||
confirmAlarm(1);
|
||||
}
|
||||
|
||||
void CAlarmWidget::slotConfirmRow2()
|
||||
{
|
||||
confirmAlarm(2);
|
||||
}
|
||||
79
product/src/gui/plugin/AlarmWidget_pad/CAlarmWidget.h
Normal file
79
product/src/gui/plugin/AlarmWidget_pad/CAlarmWidget.h
Normal file
@ -0,0 +1,79 @@
|
||||
#ifndef CALARMWINDOW_H
|
||||
#define CALARMWINDOW_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QPushButton;
|
||||
class QMouseEvent;
|
||||
class CAlarmView;
|
||||
class CAlarmDelegate;
|
||||
class CAlarmItemModel;
|
||||
|
||||
class CAlarmWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CAlarmWidget(QWidget *parent = nullptr);
|
||||
~CAlarmWidget();
|
||||
|
||||
void setAlarmModel(CAlarmItemModel * pModel);
|
||||
|
||||
void setRowHeight(const int &height);
|
||||
|
||||
void setDockColumnVisible(const int &column, const bool &visbile);
|
||||
|
||||
void updateRowHeight();
|
||||
|
||||
void updateView();
|
||||
|
||||
void setAlarmOperateEnable(const bool &bEnable);
|
||||
|
||||
void setColumnWidth(const int &column, const int &width);
|
||||
|
||||
void confirmAlarm(const int &row);
|
||||
|
||||
void setEnableTrend(bool isNeed);
|
||||
|
||||
void setEnableVideo(bool isNeed);
|
||||
|
||||
void setEnableWave(bool isNeed);
|
||||
|
||||
void setEnableLevel(bool isNeed);
|
||||
|
||||
signals:
|
||||
void alarmWidgetDoubleClicked();
|
||||
|
||||
void openVideo(int domainId,int appId,QString tag,quint64 startTime,quint64 endTime);
|
||||
|
||||
void openTrend(quint64 time_stamp,QStringList tagList);
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
bool updateAlarmOperatePerm();
|
||||
|
||||
public slots:
|
||||
void initialize();
|
||||
|
||||
void initializeEdit();
|
||||
void slotConfirmRow0();
|
||||
void slotConfirmRow1();
|
||||
void slotConfirmRow2();
|
||||
|
||||
|
||||
private:
|
||||
CAlarmView * m_pView;
|
||||
CAlarmItemModel * m_pModel;
|
||||
CAlarmDelegate * m_delegate;
|
||||
int m_userId;
|
||||
std::string m_nodeName;
|
||||
QList<int> m_listRegionOptId;
|
||||
QList<int> m_listLocationOptId;
|
||||
|
||||
QList<int> m_listRegionDelId;
|
||||
QList<int> m_listLocationDelId;
|
||||
QPushButton * m_pConfirmButtonRow0;
|
||||
QPushButton * m_pConfirmButtonRow1;
|
||||
QPushButton * m_pConfirmButtonRow2;
|
||||
};
|
||||
|
||||
#endif // ALARMWINDOW_H
|
||||
@ -0,0 +1,28 @@
|
||||
#include "CDisposalPlanDialog.h"
|
||||
#include "ui_CDisposalPlanDialog.h"
|
||||
#include "CAiAlarmMsgInfo.h"
|
||||
#include <QDate>
|
||||
CDisposalPlanDialog::CDisposalPlanDialog(const AiAlarmMsgPtr &aiptr, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CDisposalPlanDialog),
|
||||
m_aiptr(aiptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowTitle(tr("处置预案"));
|
||||
Qt::WindowFlags flags=Qt::Dialog;
|
||||
flags |=Qt::WindowCloseButtonHint;
|
||||
setWindowFlags(flags);
|
||||
|
||||
ui->time->setReadOnly(true);
|
||||
ui->content->setReadOnly(true);
|
||||
ui->displan->setReadOnly(true);
|
||||
|
||||
ui->time->setText(QDateTime::fromMSecsSinceEpoch(m_aiptr->time_stamp).toString("yyyy-MM-dd hh:mm:ss.zzz"));
|
||||
ui->content->setText(m_aiptr->content);
|
||||
ui->displan->setText(m_aiptr->disposal_plan);
|
||||
}
|
||||
|
||||
CDisposalPlanDialog::~CDisposalPlanDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
23
product/src/gui/plugin/AlarmWidget_pad/CDisposalPlanDialog.h
Normal file
23
product/src/gui/plugin/AlarmWidget_pad/CDisposalPlanDialog.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef CDISPOSALPLANDIALOG_H
|
||||
#define CDISPOSALPLANDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "CAlarmCommon.h"
|
||||
namespace Ui {
|
||||
class CDisposalPlanDialog;
|
||||
}
|
||||
|
||||
class CDisposalPlanDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CDisposalPlanDialog(const AiAlarmMsgPtr &aiptr,QWidget *parent = 0);
|
||||
~CDisposalPlanDialog();
|
||||
|
||||
private:
|
||||
Ui::CDisposalPlanDialog *ui;
|
||||
AiAlarmMsgPtr m_aiptr;
|
||||
};
|
||||
|
||||
#endif // CDISPOSALPLANDIALOG_H
|
||||
140
product/src/gui/plugin/AlarmWidget_pad/CDisposalPlanDialog.ui
Normal file
140
product/src/gui/plugin/AlarmWidget_pad/CDisposalPlanDialog.ui
Normal file
@ -0,0 +1,140 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDisposalPlanDialog</class>
|
||||
<widget class="QDialog" name="CDisposalPlanDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>391</width>
|
||||
<height>389</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>告警时间:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="time"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>告警内容:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="content">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>处置预案:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="displan">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
57
product/src/gui/plugin/AlarmWidget_pad/CMyCalendar.cpp
Normal file
57
product/src/gui/plugin/AlarmWidget_pad/CMyCalendar.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include "CMyCalendar.h"
|
||||
#include "ui_CMyCalendar.h"
|
||||
#include <pub_logger_api/logger.h>
|
||||
#include <QMessageBox>
|
||||
#include <QKeyEvent>
|
||||
CMyCalendar::CMyCalendar(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::CMyCalendar)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->calendarWidget,SIGNAL(clicked(QDate)),this,SLOT(slot_startTime(QDate)));
|
||||
connect(ui->calendarWidget_2,SIGNAL(clicked(QDate)),this,SLOT(slot_endTime(QDate)));
|
||||
connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(slot_cancle()));
|
||||
m_startTime = QDate::currentDate();
|
||||
m_endTime = QDate::currentDate();
|
||||
ui->lineEdit->setText(m_startTime.toString("yyyy-MM-dd"));
|
||||
ui->lineEdit_2->setText(m_endTime.toString("yyyy-MM-dd"));
|
||||
ui->lineEdit->setReadOnly(true);
|
||||
ui->lineEdit_2->setReadOnly(true);
|
||||
}
|
||||
|
||||
CMyCalendar::~CMyCalendar()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CMyCalendar::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if(event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void CMyCalendar::slot_endTime(QDate date)
|
||||
{
|
||||
ui->lineEdit_2->setText(date.toString("yyyy-MM-dd"));
|
||||
m_endTime = date;
|
||||
if(m_startTime.isNull() || m_endTime < m_startTime)
|
||||
{
|
||||
//QMessageBox::information(this,tr("提示"),tr("开始时间为空或结束时间小于开始时间"));
|
||||
return;
|
||||
}
|
||||
emit sig_endTimeClick(m_startTime,m_endTime);
|
||||
}
|
||||
|
||||
void CMyCalendar::slot_startTime(QDate date)
|
||||
{
|
||||
m_startTime = date;
|
||||
ui->lineEdit->setText(date.toString("yyyy-MM-dd"));
|
||||
}
|
||||
|
||||
void CMyCalendar::slot_cancle()
|
||||
{
|
||||
emit sig_cancle();
|
||||
}
|
||||
34
product/src/gui/plugin/AlarmWidget_pad/CMyCalendar.h
Normal file
34
product/src/gui/plugin/AlarmWidget_pad/CMyCalendar.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef CMYCALENDAR_H
|
||||
#define CMYCALENDAR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDate>
|
||||
|
||||
namespace Ui {
|
||||
class CMyCalendar;
|
||||
}
|
||||
|
||||
class CMyCalendar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void sig_endTimeClick(QDate startDate,QDate endDate);
|
||||
void sig_startTimeClick(QDate date);
|
||||
void sig_cancle();
|
||||
public:
|
||||
explicit CMyCalendar(QWidget *parent = 0);
|
||||
~CMyCalendar();
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *event);
|
||||
|
||||
public slots:
|
||||
void slot_endTime(QDate date);
|
||||
void slot_startTime(QDate date);
|
||||
void slot_cancle();
|
||||
private:
|
||||
Ui::CMyCalendar *ui;
|
||||
QDate m_startTime;
|
||||
QDate m_endTime;
|
||||
};
|
||||
|
||||
#endif // CMYCALENDAR_H
|
||||
140
product/src/gui/plugin/AlarmWidget_pad/CMyCalendar.ui
Normal file
140
product/src/gui/plugin/AlarmWidget_pad/CMyCalendar.ui
Normal file
@ -0,0 +1,140 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CMyCalendar</class>
|
||||
<widget class="QWidget" name="CMyCalendar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>538</width>
|
||||
<height>270</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<property name="windowOpacity">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame_alarm">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>至</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_2"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCalendarWidget" name="calendarWidget"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCalendarWidget" name="calendarWidget_2"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
21
product/src/gui/plugin/AlarmWidget_pad/CMyCheckBox.cpp
Normal file
21
product/src/gui/plugin/AlarmWidget_pad/CMyCheckBox.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "CMyCheckBox.h"
|
||||
#include <QMouseEvent>
|
||||
|
||||
CMyCheckBox::CMyCheckBox(QString text, QWidget *parent)
|
||||
:QCheckBox(text,parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CMyCheckBox::CMyCheckBox(QWidget *parent)
|
||||
:QCheckBox(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CMyCheckBox::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
setChecked(!isChecked());
|
||||
emit clicked(isChecked());
|
||||
}
|
||||
16
product/src/gui/plugin/AlarmWidget_pad/CMyCheckBox.h
Normal file
16
product/src/gui/plugin/AlarmWidget_pad/CMyCheckBox.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef MYCHECKBOX_H
|
||||
#define MYCHECKBOX_H
|
||||
|
||||
#include <QCheckBox>
|
||||
|
||||
class CMyCheckBox : public QCheckBox
|
||||
{
|
||||
public:
|
||||
CMyCheckBox(QString text,QWidget *parent = Q_NULLPTR);
|
||||
CMyCheckBox(QWidget *parent = Q_NULLPTR);
|
||||
|
||||
protected:
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
};
|
||||
|
||||
#endif // MYCHECKBOX_H
|
||||
12
product/src/gui/plugin/AlarmWidget_pad/CMyListWidget.cpp
Normal file
12
product/src/gui/plugin/AlarmWidget_pad/CMyListWidget.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "CMyListWidget.h"
|
||||
|
||||
CMyListWidget::CMyListWidget(QWidget *parent):QListWidget(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CMyListWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
this->updateGeometries();
|
||||
QListWidget::showEvent(event);
|
||||
}
|
||||
15
product/src/gui/plugin/AlarmWidget_pad/CMyListWidget.h
Normal file
15
product/src/gui/plugin/AlarmWidget_pad/CMyListWidget.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef CMYLISTWIDGET_H
|
||||
#define CMYLISTWIDGET_H
|
||||
|
||||
#include <QListWidget>
|
||||
|
||||
class CMyListWidget : public QListWidget
|
||||
{
|
||||
public:
|
||||
explicit CMyListWidget(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
};
|
||||
|
||||
#endif // CMYLISTWIDGET_H
|
||||
150
product/src/gui/plugin/AlarmWidget_pad/CPdfPrinter.cpp
Normal file
150
product/src/gui/plugin/AlarmWidget_pad/CPdfPrinter.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
#include "CPdfPrinter.h"
|
||||
#include <QDebug>
|
||||
#include <QHeaderView>
|
||||
#include <QMessageBox>
|
||||
#include <pub_logger_api/logger.h>
|
||||
#include "CAlarmView.h"
|
||||
#include "CAiAlarmTreeView.h"
|
||||
|
||||
CPdfPrinter::CPdfPrinter(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CPdfPrinter::initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CPdfPrinter::printerByModel(CAiAlarmTreeView* view, CAiAlarmTreeModel *treeModel, QString fileName)
|
||||
{
|
||||
QString sExcelFileName = fileName;
|
||||
QXlsx::Document xlsx;
|
||||
xlsx.addSheet( "智能告警" );
|
||||
// 写横向表头
|
||||
QXlsx::Format formatheader;
|
||||
formatheader.setFontBold(true);
|
||||
formatheader.setFontColor(Qt::black);
|
||||
|
||||
QXlsx::Format formatAi;
|
||||
formatAi.setFontBold(true);
|
||||
formatAi.setFontColor(Qt::red);
|
||||
|
||||
QXlsx::Format formatMergedAlm;
|
||||
formatMergedAlm.setFontBold(false);
|
||||
formatMergedAlm.setFontColor(Qt::darkGreen);
|
||||
QXlsx::Format formatAlm;
|
||||
formatAlm.setFontBold(false);
|
||||
formatAlm.setFontColor(Qt::darkYellow);
|
||||
int colcount = treeModel->columnCount();
|
||||
|
||||
for(int i=0,excelCloumn=0;i<colcount;++i)
|
||||
{
|
||||
if (view->isColumnHidden(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
xlsx.write( 1, excelCloumn +1, treeModel->headerData(i, Qt::Horizontal).toString().trimmed(),formatheader);
|
||||
excelCloumn++;
|
||||
}
|
||||
|
||||
// 写内容
|
||||
int rowNum = 1;
|
||||
CAiAlarmTreeItem *item = treeModel->getItem();
|
||||
QList<CAiAlarmTreeItem *> itemList = item->getChildItemList();
|
||||
for(int index(0);index<itemList.size();index++)
|
||||
{
|
||||
if(itemList.at(index)->isAi())
|
||||
{
|
||||
for(int j(0),excelCloumn(0);j<colcount;j++)
|
||||
{
|
||||
if (view->isColumnHidden(j))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QString sText=itemList.at(index)->data(j).toString();
|
||||
xlsx.write( rowNum +1, excelCloumn +1, sText,formatAi );
|
||||
++excelCloumn;
|
||||
}
|
||||
rowNum++;
|
||||
QList<CAiAlarmTreeItem *> itemList_ =itemList.at(index)->getChildItemList();
|
||||
for(int indexAlm(0);indexAlm<itemList_.size();indexAlm++)
|
||||
{
|
||||
for(int i(0),excelCloumn(0);i<colcount;i++)
|
||||
{
|
||||
if (view->isColumnHidden(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QString sText=itemList_.at(indexAlm)->data(i).toString();
|
||||
xlsx.write( rowNum +1, excelCloumn +1, sText,formatMergedAlm );
|
||||
++excelCloumn;
|
||||
}
|
||||
rowNum++;
|
||||
}
|
||||
}else
|
||||
{
|
||||
for(int j(0),excelCloumn(0);j<colcount;j++)
|
||||
{
|
||||
if (view->isColumnHidden(j))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QString sText=itemList.at(index)->data(j).toString();
|
||||
xlsx.write( rowNum +1, excelCloumn +1, sText,formatAlm );
|
||||
excelCloumn++;
|
||||
}
|
||||
rowNum++;
|
||||
}
|
||||
}
|
||||
|
||||
// 保存到文件
|
||||
xlsx.saveAs( sExcelFileName );
|
||||
|
||||
// 提示导出路径
|
||||
emit printResult(sExcelFileName);
|
||||
}
|
||||
|
||||
void CPdfPrinter::printerAlmByModel(CAlarmView* view, CAlarmItemModel *model, QString fileName)
|
||||
{
|
||||
QString sExcelFileName = fileName;
|
||||
QXlsx::Document xlsx;
|
||||
xlsx.addSheet( "原始告警" );
|
||||
// 写横向表头
|
||||
int rowcount=model->rowCount();
|
||||
int colcount=model->columnCount();
|
||||
|
||||
for(int i=0,excelCloumn = 0;i<colcount;++i)
|
||||
{
|
||||
if (view->isColumnHidden(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
xlsx.write( 1, excelCloumn +1, model->headerData(i, Qt::Horizontal).toString().trimmed());
|
||||
excelCloumn++;
|
||||
}
|
||||
|
||||
// 写内容
|
||||
for (int j = 0,excelCloumn = 0; j < colcount; j++) //列数
|
||||
{
|
||||
if (view->isColumnHidden(j))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rowcount; i++)
|
||||
{
|
||||
QString sText= model->data(model->index(i, j)).toString();
|
||||
xlsx.write( i+2, excelCloumn +1, sText);
|
||||
}
|
||||
|
||||
excelCloumn++;
|
||||
}
|
||||
// 保存到文件
|
||||
xlsx.saveAs( sExcelFileName );
|
||||
|
||||
// 提示导出路径
|
||||
emit printResult(sExcelFileName);
|
||||
}
|
||||
40
product/src/gui/plugin/AlarmWidget_pad/CPdfPrinter.h
Normal file
40
product/src/gui/plugin/AlarmWidget_pad/CPdfPrinter.h
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @file AlarmWidget 之前是做pdf打印,因需求修改,现在改为excel ,但是类名不变,维护请注意
|
||||
* @brief
|
||||
* @author jxd
|
||||
* @date 2020-01-08
|
||||
*/
|
||||
#ifndef CPDFPRINTER_H
|
||||
#define CPDFPRINTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
#include <QVector>
|
||||
#include <CAiAlarmTreeModel.h>
|
||||
#include <CAlarmItemModel.h>
|
||||
#include "CAiAlarmTreeView.h"
|
||||
#include "pub_excel/xlsx/xlsxdocument.h"
|
||||
#include "pub_excel/xlsx/xlsxformat.h"
|
||||
|
||||
class CPdfPrinter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CPdfPrinter(QObject *parent = nullptr);
|
||||
|
||||
void initialize();
|
||||
|
||||
signals:
|
||||
void printResult(QString fileName);
|
||||
public slots:
|
||||
void printerByModel(CAiAlarmTreeView* view, CAiAlarmTreeModel *treeModel, QString fileName);
|
||||
void printerAlmByModel(CAlarmView* view, CAlarmItemModel *model,QString fileName);
|
||||
private:
|
||||
QString m_fileName;
|
||||
QVector<bool> m_columnHidden;
|
||||
QVector<double> m_columnWidth;
|
||||
int m_headHeight;
|
||||
int m_height;
|
||||
int m_width;
|
||||
};
|
||||
#endif // CPDFPRINTER_H
|
||||
54
product/src/gui/plugin/AlarmWidget_pad/CTableViewPrinter.cpp
Normal file
54
product/src/gui/plugin/AlarmWidget_pad/CTableViewPrinter.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include "CTableViewPrinter.h"
|
||||
#include "CAlarmCommon.h"
|
||||
#include "CAlarmBaseData.h"
|
||||
CTableViewPrinter::CTableViewPrinter(CAlarmItemModel *model):
|
||||
m_pModel(model)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QVector<QString> CTableViewPrinter::getHead()
|
||||
{
|
||||
int columnCount = m_pModel->columnCount();
|
||||
QVector<QString> header;
|
||||
for(int index(0);index <columnCount;index++)
|
||||
{
|
||||
header.append(m_pModel->headerData(index,Qt::Horizontal).toString());
|
||||
}
|
||||
return header;
|
||||
}
|
||||
|
||||
QList<QVector<QString> > CTableViewPrinter::getData()
|
||||
{
|
||||
QList<QVector<QString> > data;
|
||||
QList<AlarmMsgPtr> list = m_pModel->getListShowAlarmInfo();
|
||||
for(int index(0);index<list.size();index++)
|
||||
{
|
||||
QVector<QString> content;
|
||||
//1.时间
|
||||
content.append(QDateTime::fromMSecsSinceEpoch(list.at(index)->time_stamp).toString("yyyy-MM-dd hh:mm:ss.zzz"));
|
||||
//2.优先级
|
||||
content.append(CAlarmBaseData::instance()->queryPriorityDesc(list.at(index)->priority));
|
||||
//3.位置
|
||||
content.append(CAlarmBaseData::instance()->queryLocationDesc(list.at(index)->location_id));
|
||||
//4.责任区
|
||||
content.append(CAlarmBaseData::instance()->queryRegionDesc(list.at(index)->region_id));
|
||||
//5.类型
|
||||
content.append(CAlarmBaseData::instance()->queryAlarmTypeDesc(list.at(index)->alm_type));
|
||||
//6.状态
|
||||
content.append(CAlarmBaseData::instance()->queryAlarmStatusDesc(list.at(index)->alm_status));
|
||||
//7.确认状态
|
||||
if(list.at(index)->logic_state == E_ALS_ALARM || list.at(index)->logic_state == E_ALS_RETURN)
|
||||
{
|
||||
content.append(QObject::tr("未确认"));
|
||||
}else
|
||||
{
|
||||
content.append(QObject::tr("已确认"));
|
||||
}
|
||||
//8.内容
|
||||
content.append(list.at(index)->content);
|
||||
data.append(content);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
15
product/src/gui/plugin/AlarmWidget_pad/CTableViewPrinter.h
Normal file
15
product/src/gui/plugin/AlarmWidget_pad/CTableViewPrinter.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef CTABLEVIEWPRINTER_H
|
||||
#define CTABLEVIEWPRINTER_H
|
||||
#include "CAlarmItemModel.h"
|
||||
class QVariant;
|
||||
class CTableViewPrinter
|
||||
{
|
||||
public:
|
||||
CTableViewPrinter(CAlarmItemModel *model);
|
||||
QVector<QString> getHead();
|
||||
QList<QVector<QString> > getData();
|
||||
private:
|
||||
CAlarmItemModel * m_pModel;
|
||||
};
|
||||
|
||||
#endif // CTABLEVIEWPRINTER_H
|
||||
42
product/src/gui/plugin/AlarmWidget_pad/CTreeViewPrinter.cpp
Normal file
42
product/src/gui/plugin/AlarmWidget_pad/CTreeViewPrinter.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include "CTreeViewPrinter.h"
|
||||
#include "CAiAlarmTreeItem.h"
|
||||
CTreeViewPrinter::CTreeViewPrinter(CAiAlarmTreeModel *model):
|
||||
m_pModel(model)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QVector<QString> CTreeViewPrinter::getHead()
|
||||
{
|
||||
int columnCount = m_pModel->columnCount();
|
||||
QVector<QString> header;
|
||||
for(int index(0);index <columnCount;index++)
|
||||
{
|
||||
header.append(m_pModel->headerData(index,Qt::Horizontal).toString());
|
||||
}
|
||||
return header;
|
||||
}
|
||||
|
||||
QList<QVector<QString> > CTreeViewPrinter::getData()
|
||||
{
|
||||
QList<QVector<QString> > data;
|
||||
CAiAlarmTreeItem *item = ((CAiAlarmTreeModel*)m_pModel)->getItem();
|
||||
QList<CAiAlarmTreeItem *> itemList = item->getChildItemList();
|
||||
for(int index(0);index<itemList.size();index++)
|
||||
{
|
||||
QVector<QString> content;
|
||||
content = itemList.at(index)->getContent();
|
||||
data.append(content);
|
||||
if(itemList.at(index)->isAi())
|
||||
{
|
||||
QList<CAiAlarmTreeItem *> itemlist = itemList.at(index)->getChildItemList();
|
||||
for(int dex(0);dex<itemlist.size();dex++)
|
||||
{
|
||||
QVector<QString> almInfo;
|
||||
almInfo = itemlist.at(dex)->getContent();
|
||||
data.append(almInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
15
product/src/gui/plugin/AlarmWidget_pad/CTreeViewPrinter.h
Normal file
15
product/src/gui/plugin/AlarmWidget_pad/CTreeViewPrinter.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef CTREEVIEWPRINTER_H
|
||||
#define CTREEVIEWPRINTER_H
|
||||
#include "CAiAlarmTreeModel.h"
|
||||
class QVariant;
|
||||
class CTreeViewPrinter
|
||||
{
|
||||
public:
|
||||
CTreeViewPrinter(CAiAlarmTreeModel *model);
|
||||
QVector<QString> getHead();
|
||||
QList<QVector<QString> > getData();
|
||||
private:
|
||||
CAiAlarmTreeModel * m_pModel;
|
||||
};
|
||||
|
||||
#endif // CTREEVIEWPRINTER_H
|
||||
75
product/src/gui/plugin/AlarmWidget_pad/main.cpp
Normal file
75
product/src/gui/plugin/AlarmWidget_pad/main.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
#include <QApplication>
|
||||
#include "CAlarmPlugin.h"
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include "net_msg_bus_api/MsgBusApi.h"
|
||||
#include "dp_chg_data_api/CDpcdaForApp.h"
|
||||
#include "service/perm_mng_api/PermMngApi.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
//<初始化消息总线
|
||||
QStringList arguments=QCoreApplication::arguments();
|
||||
std::string name="admin";
|
||||
std::string password ="admin";
|
||||
int group =1;
|
||||
for(int index(0);index<arguments.size();index++)
|
||||
{
|
||||
if(arguments.at(index) == "-username")
|
||||
{
|
||||
if(index+1<arguments.size())
|
||||
{
|
||||
QString st = arguments.at(index+1);
|
||||
name =st.toStdString();
|
||||
}
|
||||
}
|
||||
if(arguments.at(index) == "-password")
|
||||
{
|
||||
if(index+1<arguments.size())
|
||||
{
|
||||
QString st = arguments.at(index+1);
|
||||
password =st.toStdString();
|
||||
}
|
||||
}
|
||||
if(arguments.at(index) == "-group")
|
||||
{
|
||||
if(index+1<arguments.size())
|
||||
{
|
||||
QString st = arguments.at(index+1);
|
||||
group =st.toInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
iot_public::StartLogSystem("HMI", "hmi");
|
||||
if (!(iot_net::initMsgBus("HMI", "HMI")))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
iot_service::CPermMngApiPtr perm = iot_service::getPermMngInstance("base");
|
||||
if(!perm || PERM_NORMAL != perm->PermDllInit())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(perm->SysLogin(name, password, group, 12*60*60, "hmi") != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
{
|
||||
CAlarmPlugin n(NULL, false);
|
||||
n.initialize(E_Alarm_Dock);
|
||||
//n.initialize(E_Alarm_Window);
|
||||
|
||||
n.show();
|
||||
app.exec();
|
||||
}
|
||||
|
||||
//<释放消息总线
|
||||
iot_net::releaseMsgBus();
|
||||
iot_public::StopLogSystem();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
81
product/src/gui/plugin/BatchOperation/BatchOperation.pro
Normal file
81
product/src/gui/plugin/BatchOperation/BatchOperation.pro
Normal file
@ -0,0 +1,81 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2024-08-12T13:59:55
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui sql
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += plugin
|
||||
|
||||
TARGET = BatchOperation
|
||||
TEMPLATE = lib
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which has been marked as deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
|
||||
SOURCES += \
|
||||
../../../../../platform/src/include/service/operate_server_api/JsonOptCommand.cpp \
|
||||
main.cpp \
|
||||
CBatchOperPluginWidget.cpp \
|
||||
CBatchOperation.cpp \
|
||||
CBatchOperationCollect.cpp \
|
||||
CustonHeadView.cpp \
|
||||
CBatchOperationModel.cpp \
|
||||
CDbInterface.cpp \
|
||||
CBatchOpeDelegate.cpp \
|
||||
CustomFilterModel.cpp \
|
||||
CInputDialog.cpp
|
||||
|
||||
HEADERS += \
|
||||
../../../../../platform/src/include/service/operate_server_api/JsonMessageStruct.h \
|
||||
../../../../../platform/src/include/service/operate_server_api/JsonOptCommand.h \
|
||||
CBatchOperPluginWidget.h \
|
||||
CBatchOperation.h \
|
||||
CBatchOperationCollect.h \
|
||||
BatchOperationComm.h \
|
||||
CustonHeadView.h \
|
||||
CBatchOperationModel.h \
|
||||
CDbInterface.h \
|
||||
CBatchOpeDelegate.h \
|
||||
CustomFilterModel.h \
|
||||
CInputDialog.h
|
||||
|
||||
FORMS += \
|
||||
CBatchOperation.ui \
|
||||
CInputDialog.ui
|
||||
|
||||
LIBS += \
|
||||
-llog4cplus \
|
||||
-lpub_logger_api \
|
||||
-lprotobuf \
|
||||
-lnet_msg_bus_api \
|
||||
-ldb_base_api \
|
||||
-ldb_api_ex \
|
||||
-lpub_sysinfo_api \
|
||||
-ldp_chg_data_api \
|
||||
-lrdb_api \
|
||||
-lrdb_net_api \
|
||||
-lpub_utility_api \
|
||||
-lperm_mng_api
|
||||
|
||||
|
||||
include($$PWD/../../../idl_files/idl_files.pri)
|
||||
|
||||
COMMON_PRI=$$PWD/../../../common.pri
|
||||
exists($$COMMON_PRI) {
|
||||
include($$COMMON_PRI)
|
||||
}else {
|
||||
error("FATAL error: can not find common.pri")
|
||||
}
|
||||
92
product/src/gui/plugin/BatchOperation/BatchOperationComm.h
Normal file
92
product/src/gui/plugin/BatchOperation/BatchOperationComm.h
Normal file
@ -0,0 +1,92 @@
|
||||
#ifndef BATCHOPERATIONCOMM_H
|
||||
#define BATCHOPERATIONCOMM_H
|
||||
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
|
||||
enum EPointType
|
||||
{
|
||||
EN_ALL,
|
||||
EN_ANALOG,
|
||||
EN_DIGITAL,
|
||||
EN_MIX,
|
||||
EN_ACCUML,
|
||||
};
|
||||
|
||||
struct DataPoint
|
||||
{
|
||||
QString keyTag;
|
||||
QString pointTag;
|
||||
QString tableName;
|
||||
QString tagDesc;
|
||||
QString tableDesc;
|
||||
QString stateTextName;
|
||||
QString controStateName;
|
||||
QString loctionName;
|
||||
QString unit;
|
||||
QString resText;
|
||||
|
||||
int dataType;
|
||||
int appId;
|
||||
int region;
|
||||
int locationId;
|
||||
int domainId;
|
||||
float value_ai;
|
||||
int value_di;
|
||||
double value_pi;
|
||||
int value_mi;
|
||||
double setValue;
|
||||
bool isEnableContro;
|
||||
QMap<int ,QString> options;
|
||||
QMap<int , QString> controlOpt;
|
||||
|
||||
DataPoint()
|
||||
{
|
||||
keyTag = "";
|
||||
pointTag = "";
|
||||
tableName = "";
|
||||
tagDesc = "";
|
||||
tableDesc = "";
|
||||
stateTextName = "";
|
||||
controStateName = "";
|
||||
loctionName = "";
|
||||
unit = "";
|
||||
resText = "无";
|
||||
|
||||
appId = 0;
|
||||
region = 0;
|
||||
locationId = 0;
|
||||
domainId = 0;
|
||||
value_ai = 0;
|
||||
value_di = 0;
|
||||
value_pi = 0;
|
||||
value_mi = 0;
|
||||
setValue = 0;
|
||||
dataType = -1;
|
||||
isEnableContro = true;
|
||||
options.clear();
|
||||
controlOpt.clear();
|
||||
}
|
||||
};
|
||||
|
||||
struct STOptTagInfo
|
||||
{
|
||||
QString keyIdTag;
|
||||
int optType;
|
||||
qint64 optTime;
|
||||
int locationId;
|
||||
int appId;
|
||||
double setValue;
|
||||
int nIsSet;
|
||||
QString stateText;
|
||||
QString hostName;
|
||||
QString userName;
|
||||
QString userGroup;
|
||||
|
||||
QString tagName;
|
||||
QString devName;
|
||||
QString table;
|
||||
};
|
||||
|
||||
|
||||
#endif // BATCHOPERATIONCOMM_H
|
||||
91
product/src/gui/plugin/BatchOperation/CBatchOpeDelegate.cpp
Normal file
91
product/src/gui/plugin/BatchOperation/CBatchOpeDelegate.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
#include "CBatchOpeDelegate.h"
|
||||
#include "BatchOperationComm.h"
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
CBatchOpeDelegate::CBatchOpeDelegate(QObject *parent)
|
||||
: QStyledItemDelegate (parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QWidget *CBatchOpeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
if(!index.isValid()) return nullptr;
|
||||
|
||||
QModelIndex sourceIndex = index;
|
||||
const QSortFilterProxyModel* proxyModel = qobject_cast<const QSortFilterProxyModel*>(index.model());
|
||||
if (proxyModel) {
|
||||
sourceIndex = proxyModel->mapToSource(index);
|
||||
}
|
||||
|
||||
if (sourceIndex.column() == 2)
|
||||
{
|
||||
QComboBox *comboBox;
|
||||
QLineEdit *lineEdit;
|
||||
QDoubleValidator *validator;
|
||||
QMap<int ,QString> options;
|
||||
int type = sourceIndex.model()->data(sourceIndex,Qt::UserRole + 6).toInt();
|
||||
options.clear();
|
||||
switch (type) {
|
||||
case EN_ANALOG:
|
||||
lineEdit = new QLineEdit(parent);
|
||||
validator = new QDoubleValidator(-1e10, 1e10, 6, lineEdit);
|
||||
lineEdit->setValidator(validator);
|
||||
return lineEdit;
|
||||
case EN_DIGITAL:
|
||||
case EN_MIX:
|
||||
comboBox = new QComboBox(parent);
|
||||
options = sourceIndex.model()->data(sourceIndex, Qt::UserRole + 11).value<QMap<int ,QString>>();
|
||||
foreach(const int &str,options.keys())
|
||||
{
|
||||
comboBox->addItem( options.value(str) ,str);
|
||||
}
|
||||
return comboBox;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}else if(sourceIndex.column() == 1 || sourceIndex.column() == 3 ||sourceIndex.column() == 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return QStyledItemDelegate::createEditor(parent, option, sourceIndex);
|
||||
}
|
||||
|
||||
void CBatchOpeDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
if(!index.isValid()) return;
|
||||
|
||||
QModelIndex sourceIndex = index;
|
||||
if (sourceIndex.column() == 2) {
|
||||
int type = sourceIndex.model()->data(sourceIndex, Qt::UserRole + 6).toInt();
|
||||
if (type == EN_ANALOG || type == EN_ACCUML) {
|
||||
QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
|
||||
lineEdit->setText(QString::number(sourceIndex.model()->data(sourceIndex, Qt::EditRole).toDouble() , 'f'));
|
||||
} else if (type == EN_DIGITAL || type == EN_MIX) {
|
||||
QComboBox *comboBox = qobject_cast<QComboBox*>(editor);
|
||||
comboBox->setCurrentText(sourceIndex.model()->data(sourceIndex, Qt::EditRole).toString());
|
||||
}
|
||||
} else {
|
||||
QStyledItemDelegate::setEditorData(editor, sourceIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void CBatchOpeDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
{
|
||||
if(!index.isValid()) return;
|
||||
|
||||
QModelIndex sourceIndex = index;
|
||||
if (sourceIndex.column() == 2) {
|
||||
int type = sourceIndex.model()->data(sourceIndex, Qt::UserRole + 6).toInt();
|
||||
if (type == EN_ANALOG || type == EN_ACCUML) {
|
||||
QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
|
||||
model->setData(sourceIndex, lineEdit->text(), Qt::EditRole);
|
||||
} else if (type == EN_DIGITAL || type == EN_MIX) {
|
||||
QComboBox *comboBox = qobject_cast<QComboBox*>(editor);
|
||||
model->setData(sourceIndex, comboBox->currentData(), Qt::EditRole);
|
||||
}
|
||||
} else {
|
||||
QStyledItemDelegate::setModelData(editor, model, sourceIndex);
|
||||
}
|
||||
}
|
||||
20
product/src/gui/plugin/BatchOperation/CBatchOpeDelegate.h
Normal file
20
product/src/gui/plugin/BatchOperation/CBatchOpeDelegate.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef CBATCHOPEDELEGATE_H
|
||||
#define CBATCHOPEDELEGATE_H
|
||||
|
||||
#include <QItemDelegate>
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
class CBatchOpeDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CBatchOpeDelegate(QObject *parent = nullptr);
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||
|
||||
};
|
||||
|
||||
#endif // CBATCHOPEDELEGATE_H
|
||||
@ -0,0 +1,19 @@
|
||||
#include "CBatchOperPluginWidget.h"
|
||||
|
||||
CBatchOperPluginWidget::CBatchOperPluginWidget(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CBatchOperPluginWidget::createWidget(QWidget *parent, bool editMode, QWidget **widget, IPluginWidget **pTrendWindow, QVector<void *> ptrVec)
|
||||
{
|
||||
CBatchOperation *pWidget = new CBatchOperation(parent, editMode);
|
||||
*widget = (QWidget *)pWidget;
|
||||
*pTrendWindow = (IPluginWidget *)pWidget;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBatchOperPluginWidget::release()
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
#ifndef CPCSBATCHOPERPLUGINWIDGET_H
|
||||
#define CPCSBATCHOPERPLUGINWIDGET_H
|
||||
|
||||
#include <QObject>
|
||||
#include "GraphShape/CPluginWidget.h"
|
||||
#include "CBatchOperation.h"
|
||||
|
||||
class CBatchOperPluginWidget : public QObject,public CPluginWidgetInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID HMI_WidgetPlugin_IID)
|
||||
Q_INTERFACES(CPluginWidgetInterface)
|
||||
|
||||
public:
|
||||
explicit CBatchOperPluginWidget(QObject *parent = nullptr);
|
||||
|
||||
bool createWidget(QWidget *parent, bool editMode, QWidget **widget, IPluginWidget **pTrendWindow, QVector<void *> ptrVec);
|
||||
void release();
|
||||
};
|
||||
|
||||
#endif // CPCSBATCHOPERPLUGINWIDGET_H
|
||||
618
product/src/gui/plugin/BatchOperation/CBatchOperation.cpp
Normal file
618
product/src/gui/plugin/BatchOperation/CBatchOperation.cpp
Normal file
@ -0,0 +1,618 @@
|
||||
#include "CBatchOperation.h"
|
||||
#include "ui_CBatchOperation.h"
|
||||
#include "pub_utility_api/FileStyle.h"
|
||||
#include "pub_sysinfo_api/SysInfoApi.h"
|
||||
#include "perm_mng_api/PermMngApi.h"
|
||||
#include "pub_logger_api/logger.h"
|
||||
|
||||
#include "dbms/rdb_api/CRdbAccess.h"
|
||||
#include "dbms/db_api_ex/CDbApi.h"
|
||||
#include "BatchOperationComm.h"
|
||||
#include "CustonHeadView.h"
|
||||
#include "CBatchOpeDelegate.h"
|
||||
#include "CustomFilterModel.h"
|
||||
#include "CInputDialog.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QByteArray>
|
||||
#include <QJsonArray>
|
||||
#include <QFile>
|
||||
#include <QCheckBox>
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace iot_dbms;
|
||||
using namespace iot_public;
|
||||
using namespace iot_service;
|
||||
|
||||
CBatchOperation::CBatchOperation(QWidget *parent , bool editMode) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::CBatchOperation),
|
||||
m_communicator(NULL),
|
||||
header(Q_NULLPTR),
|
||||
filterModel(Q_NULLPTR),
|
||||
m_BatchOpCollect(Q_NULLPTR),
|
||||
m_pCollectThread(Q_NULLPTR),
|
||||
m_Model(Q_NULLPTR)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
initStyleSheet();
|
||||
|
||||
if(!editMode)
|
||||
{
|
||||
if(!iot_public::createSysInfoInstance(m_sysInfoPtr))
|
||||
{
|
||||
LOGERROR("创建系统信息访问库实例失败!");
|
||||
return;
|
||||
}
|
||||
initMsg();
|
||||
readNodeInfo();
|
||||
initialize();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CBatchOperation::~CBatchOperation()
|
||||
{
|
||||
if( m_BatchOpCollect )
|
||||
{
|
||||
emit releaseCollectThread();
|
||||
}
|
||||
m_BatchOpCollect = Q_NULLPTR;
|
||||
|
||||
if(m_pCollectThread)
|
||||
{
|
||||
m_pCollectThread->quit();
|
||||
m_pCollectThread->wait();
|
||||
}
|
||||
m_pCollectThread = Q_NULLPTR;
|
||||
|
||||
CDbInterface::instance()->destory();
|
||||
|
||||
if(m_Model)
|
||||
{
|
||||
delete m_Model;
|
||||
}
|
||||
m_Model = Q_NULLPTR;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
int CBatchOperation::tableNameToEnum(const QString &tableName)
|
||||
{
|
||||
if(tableName == "analog")
|
||||
{
|
||||
return EN_ANALOG;
|
||||
}
|
||||
else if(tableName == "digital")
|
||||
{
|
||||
return EN_DIGITAL;
|
||||
}
|
||||
else if(tableName == "accuml")
|
||||
{
|
||||
return EN_ACCUML;
|
||||
}
|
||||
else if(tableName == "mix")
|
||||
{
|
||||
return EN_MIX;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void CBatchOperation::setParaFromView( const int ®ionId , const QString &str)
|
||||
{
|
||||
Q_UNUSED(regionId);
|
||||
|
||||
//处理数据
|
||||
if( str.isEmpty() ) return;
|
||||
QString data = str;
|
||||
QStringList list = data.split(",");
|
||||
if( !list.isEmpty() )
|
||||
{
|
||||
emit updateData(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CBatchOperation::initStyleSheet()
|
||||
{
|
||||
QString qss = QString();
|
||||
std::string strFullPath = iot_public::CFileStyle::getPathOfStyleFile("public.qss") ;
|
||||
QFile qssfile1(QString::fromStdString(strFullPath));
|
||||
qssfile1.open(QFile::ReadOnly);
|
||||
if (qssfile1.isOpen())
|
||||
{
|
||||
qss += QLatin1String(qssfile1.readAll());
|
||||
qssfile1.close();
|
||||
}
|
||||
qssfile1.close();
|
||||
|
||||
strFullPath = iot_public::CFileStyle::getPathOfStyleFile("BatchOperation.qss") ;
|
||||
QFile qssfile2(QString::fromStdString(strFullPath));
|
||||
qssfile2.open(QFile::ReadOnly);
|
||||
if (qssfile2.isOpen())
|
||||
{
|
||||
qss += QLatin1String(qssfile2.readAll());
|
||||
qssfile2.close();
|
||||
}
|
||||
qssfile2.close();
|
||||
|
||||
if(!qss.isEmpty())
|
||||
{
|
||||
setStyleSheet(qss);
|
||||
}
|
||||
}
|
||||
|
||||
void CBatchOperation::initMsg()
|
||||
{
|
||||
if(m_communicator == NULL)
|
||||
{
|
||||
m_communicator = new iot_net::CMbCommunicator();
|
||||
}
|
||||
}
|
||||
|
||||
void CBatchOperation::readNodeInfo()
|
||||
{
|
||||
if(m_sysInfoPtr->getLocalNodeInfo(m_nodeInfo) == iotFailed)
|
||||
{
|
||||
LOGERROR("获取本机节点信息失败!");
|
||||
}
|
||||
}
|
||||
|
||||
void CBatchOperation::initialize()
|
||||
{
|
||||
QStringList list ;
|
||||
list<<tr("全部")<<tr("模拟量")<<tr("数字量")<<tr("混合量");
|
||||
ui->m_typeCb->addItems(list);
|
||||
ui->opertionBtn->setVisible(false);
|
||||
|
||||
//初始化表格模型数据
|
||||
m_Model = new CBatchOperationModel(this);
|
||||
filterModel = new CustomFilterModel(this);
|
||||
filterModel->setSourceModel(m_Model);
|
||||
ui->tableView->setModel(filterModel);
|
||||
ui->tableView->setAlternatingRowColors(true);
|
||||
|
||||
CBatchOpeDelegate *delegate = new CBatchOpeDelegate(ui->tableView);
|
||||
ui->tableView->setItemDelegate(delegate);
|
||||
|
||||
// 设置自定义的表头
|
||||
header = new CustonHeadView(Qt::Horizontal, ui->tableView);
|
||||
header->setSectionResizeMode(QHeaderView::Interactive);
|
||||
header->setStretchLastSection(true);
|
||||
ui->tableView->setHorizontalHeader(header);
|
||||
ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
ui->tableView->update();
|
||||
|
||||
connect(ui->tableView , &QTableView::customContextMenuRequested , this , &CBatchOperation::showContextMenu);
|
||||
connect(header, &CustonHeadView::toggleCheckState, m_Model, &CBatchOperationModel::setAllChecked);
|
||||
connect(m_Model, &CBatchOperationModel::itemChanged, [this](QStandardItem *item) {
|
||||
if (item->column() == 0 && item->isCheckable()) {
|
||||
bool allChecked = true;
|
||||
|
||||
for (int row = 0; row < this->m_Model->rowCount(); ++row) {
|
||||
QStandardItem *checkItem = this->m_Model->item(row, 0);
|
||||
if ( (m_Model->flags(checkItem->index())& Qt::ItemIsUserCheckable) && (checkItem->checkState() == Qt::Unchecked)) {
|
||||
allChecked = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this->header->setChecked(allChecked);
|
||||
}
|
||||
});
|
||||
connect(this , &CBatchOperation::updateData , this , &CBatchOperation::brushTableView);
|
||||
connect(ui->m_typeCb, QOverload<int>::of(&QComboBox::currentIndexChanged),filterModel , &CustomFilterModel::setFilterCriteria);
|
||||
connect(ui->m_typeCb ,QOverload<int>::of(&QComboBox::currentIndexChanged) , [=](int index){
|
||||
if( index == 0)
|
||||
{
|
||||
ui->opertionBtn->setVisible(false);
|
||||
}else
|
||||
{
|
||||
ui->opertionBtn->setVisible(true);
|
||||
}
|
||||
});
|
||||
connect(ui->opertionBtn , &QPushButton::clicked , this , &CBatchOperation::slotOperationBtnClick);
|
||||
connect(ui->exebtn , &QPushButton::clicked , this ,&CBatchOperation::slotExecuteBtnClick);
|
||||
|
||||
connect( this , &CBatchOperation::updateTableRow , [=](int row , bool res){
|
||||
refreshData(row , res);
|
||||
});
|
||||
|
||||
//初始化接受信息
|
||||
m_BatchOpCollect = new CBatchOperationCollect;
|
||||
m_pCollectThread = new QThread(this);
|
||||
m_BatchOpCollect->moveToThread(m_pCollectThread);
|
||||
connect(m_pCollectThread, &QThread::finished, m_pCollectThread, &QThread::deleteLater);
|
||||
connect(this, &CBatchOperation::releaseCollectThread, m_BatchOpCollect, &CBatchOperationCollect::release, Qt::BlockingQueuedConnection);
|
||||
connect(m_BatchOpCollect , &CBatchOperationCollect::signal_updateRes , this , &CBatchOperation::slotUpdataRes);
|
||||
m_pCollectThread->start();
|
||||
|
||||
}
|
||||
|
||||
QString CBatchOperation::permCheck(int locationId, int regionId)
|
||||
{
|
||||
|
||||
int level;
|
||||
int loginSec;
|
||||
CPermMngApiPtr permMng = getPermMngInstance("base");
|
||||
if(permMng != NULL)
|
||||
{
|
||||
if(permMng->PermDllInit() != PERM_NORMAL)
|
||||
{
|
||||
return tr("获取登录信息失败!");
|
||||
}else
|
||||
{
|
||||
std::string instanceName = "DevRealDataWidget";
|
||||
if(PERM_NORMAL != permMng->CurUser(m_userId, m_userGroupId, level, loginSec, instanceName))
|
||||
{
|
||||
m_userId = -1;
|
||||
return tr("获取登录账户失败!");
|
||||
}
|
||||
SSpeFuncDef speFunc;
|
||||
speFunc.location_id = locationId;
|
||||
speFunc.region_id = regionId;
|
||||
speFunc.func_define = "FUNC_SPE_OPT_OVERRIDE";
|
||||
if (permMng->PermCheck(PERM_SPE_FUNC_DEF, &speFunc) == PERM_PERMIT)
|
||||
return "";
|
||||
else
|
||||
{
|
||||
QString mess = QString(tr("无标签操作权限!"));
|
||||
return mess;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tr("获取登录信息失败!");
|
||||
}
|
||||
|
||||
void CBatchOperation::brushTableView(const QStringList &strList)
|
||||
{
|
||||
if( strList.isEmpty()) return;
|
||||
m_dataPoint.clear();
|
||||
QMap<QString , QString> searchMap;
|
||||
searchMap.clear();
|
||||
searchMap = CDbInterface::instance()->searchPointInfo(strList);
|
||||
foreach (QString var, strList)
|
||||
{
|
||||
int count = var.count(".");
|
||||
QString keyTag = var;
|
||||
QString pointTag = var.section('.', 3, count - 1);
|
||||
if( searchMap.contains(pointTag))
|
||||
{
|
||||
QString str = searchMap.value(pointTag);
|
||||
DataPoint data;
|
||||
data.keyTag = keyTag;
|
||||
data.pointTag = pointTag;
|
||||
data.tableName = var.section('.', 2, 2);
|
||||
QString appName = var.section('.', 1, 1);
|
||||
data.loctionName = var.section('.', 0, 0);
|
||||
|
||||
data.tagDesc = str.section(',' , 0 ,0);
|
||||
data.tableDesc = str.section(',',1 ,1);
|
||||
data.dataType = tableNameToEnum(data.tableName);
|
||||
if(data.dataType == EN_ANALOG)
|
||||
data.unit = str.section(",", 2, 2);
|
||||
else if(data.dataType == EN_DIGITAL || data.dataType == EN_MIX)
|
||||
{
|
||||
data.stateTextName = str.section(",", 2, 2);
|
||||
data.controStateName = str.section(',' , 5);
|
||||
CDbInterface::instance()->getStateTextList(data.stateTextName, data.options );
|
||||
CDbInterface::instance()->getControlList(data.controStateName, data.controlOpt );
|
||||
if( data.controlOpt.isEmpty()) data.isEnableContro = false;
|
||||
else
|
||||
data.setValue = data.controlOpt.firstKey();
|
||||
|
||||
}
|
||||
else {
|
||||
//其他类型均过滤
|
||||
continue;
|
||||
}
|
||||
data.region = str.section(',' , 3 ,3 ).toInt();
|
||||
data.locationId = str.section(',' , 4, 4).toInt();
|
||||
|
||||
data.appId = getAppIdByName(appName);
|
||||
data.domainId = m_nodeInfo.nDomainId;
|
||||
|
||||
QVariantList list = CDbInterface::instance()->rdbNetGetByKey(data.appId , data.tableName , data.pointTag , "value" , data.domainId);
|
||||
if(list.size() < 2) continue;
|
||||
switch (data.dataType)
|
||||
{
|
||||
case EN_ANALOG:
|
||||
data.value_ai = list[1].toFloat();
|
||||
break;
|
||||
case EN_ACCUML:
|
||||
data.value_pi = list[1].toDouble();
|
||||
break;
|
||||
case EN_DIGITAL:
|
||||
data.value_di = list[1].toInt();
|
||||
break;
|
||||
case EN_MIX:
|
||||
data.value_mi = list[1].toInt();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_dataPoint.push_back(data);
|
||||
}
|
||||
}
|
||||
m_Model->updateDataPoint(m_dataPoint);
|
||||
|
||||
}
|
||||
|
||||
int CBatchOperation::getAppIdByName(const QString &appName)
|
||||
{
|
||||
SAppInfo stAppInfo;
|
||||
if(m_sysInfoPtr)
|
||||
m_sysInfoPtr->getAppInfoByName(appName.toStdString(), stAppInfo);
|
||||
|
||||
return stAppInfo.nId;
|
||||
}
|
||||
|
||||
void CBatchOperation::slotExecuteBtnClick()
|
||||
{
|
||||
recordSendMess.clear();
|
||||
sendCtrTagInfo(false);
|
||||
}
|
||||
|
||||
bool CBatchOperation::sendCtrTagInfo(bool isEnable)
|
||||
{
|
||||
//获取所有勾选状态的item
|
||||
CBatchOperationModel *sourceModel = qobject_cast<CBatchOperationModel*>(filterModel->sourceModel());
|
||||
if( !sourceModel ) return false;
|
||||
|
||||
for (int row = 0; row < sourceModel->rowCount(); ++row)
|
||||
{
|
||||
QStandardItem *item = sourceModel->item(row, 0);
|
||||
QModelIndex indexItem = sourceModel->index(row , 0);
|
||||
if (item && item->isCheckable() && item->checkState() == Qt::Checked)
|
||||
{
|
||||
int location = sourceModel->data(indexItem , Qt::UserRole + 8).toInt();
|
||||
int region = sourceModel->data(indexItem , Qt::UserRole + 10).toInt();
|
||||
QString desc = sourceModel->data(indexItem , Qt::DisplayRole).toString();
|
||||
QString retStr = checkPerm(location, region);
|
||||
if (!retStr.isEmpty())
|
||||
{
|
||||
QString meg = QString(tr("测点“%1”,%2")).arg(desc).arg(retStr);
|
||||
sourceModel->refreshRow(row , false , meg);
|
||||
continue;
|
||||
}
|
||||
|
||||
STOptTagInfo info;
|
||||
info.tagName = "";
|
||||
info.setValue = sourceModel->data(indexItem , Qt::UserRole + 12).toDouble();
|
||||
info.nIsSet = isEnable?1:0;// 0:取消;1:设置;
|
||||
info.optType = MT_OPT_TAG_VALUE_SET;
|
||||
info.tagName = sourceModel->data(indexItem , Qt::UserRole + 2).toString();
|
||||
info.keyIdTag = sourceModel->data(indexItem , Qt::UserRole + 1 ).toString().section('.' , 2);
|
||||
info.appId = sourceModel->data(indexItem , Qt::UserRole + 7).toInt();
|
||||
info.locationId = location;
|
||||
|
||||
if (!OptTagInfo(info))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
recordSendMess.insert(info.keyIdTag, indexItem.row());
|
||||
sourceModel->refreshRow(indexItem.row() , false , tr("控制进行中"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBatchOperation::createReqHead(SOptReqHead &head, const STOptTagInfo &info)
|
||||
{
|
||||
std::string instanceName = "BatchOpeaWidget";
|
||||
SNodeInfo& nodeInfo = m_nodeInfo;
|
||||
head.strSrcTag = "BatchOpeaWidget";
|
||||
head.nSrcDomainID = nodeInfo.nDomainId;
|
||||
head.nDstDomainID = nodeInfo.nDomainId;
|
||||
head.nAppID = info.appId;
|
||||
head.strHostName = nodeInfo.strName;
|
||||
head.strInstName = instanceName;
|
||||
head.strCommName = m_communicator->getName();
|
||||
head.nUserID = m_userId;
|
||||
head.nUserGroupID = m_userGroupId;
|
||||
head.nOptTime = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBatchOperation::OptTagInfo(const STOptTagInfo &info)
|
||||
{
|
||||
iot_net::CMbMessage msg;
|
||||
msg.setMsgType(MT_OPT_CTRL_DOWN_EXECUTE);
|
||||
msg.setSubject(info.appId, CH_HMI_TO_OPT_OPTCMD_DOWN);
|
||||
|
||||
SOptCtrlRequest socReq;
|
||||
SOptCtrlReqQueue sosRq;
|
||||
|
||||
if(!createReqHead(socReq.stHead, info))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
sosRq.strKeyIdTag = info.keyIdTag.toStdString();
|
||||
sosRq.nCtrlType = 1;
|
||||
sosRq.dTargetValue = info.setValue;
|
||||
socReq.vecOptCtrlQueue.push_back(sosRq);
|
||||
|
||||
std::string content=COptCtrlRequest::generate(socReq);
|
||||
msg.setData(content);
|
||||
|
||||
LOGERROR("deviceControl():命令执行:%s" , content.c_str());
|
||||
|
||||
if (!m_communicator->sendMsgToDomain(msg, socReq.stHead.nDstDomainID))
|
||||
{
|
||||
QString mess = QString(tr("下发取消命令失败"));
|
||||
slotShowMess(mess);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CBatchOperation::slotShowMess(const QString &mess)
|
||||
{
|
||||
QMessageBox::warning(this, tr("提示"), mess, QMessageBox::Ok);
|
||||
}
|
||||
|
||||
void CBatchOperation::showEvent(QShowEvent *event)
|
||||
{
|
||||
QWidget::showEvent(event);
|
||||
ui->tableView->horizontalHeader()->resizeSection(0, 360); //设置列宽在所有模型导入之后
|
||||
}
|
||||
|
||||
QString CBatchOperation::checkPerm(int location, int region)
|
||||
{
|
||||
int level;
|
||||
int loginSec;
|
||||
CPermMngApiPtr permMng = getPermMngInstance("base");
|
||||
if(permMng != NULL)
|
||||
{
|
||||
if(permMng->PermDllInit() != PERM_NORMAL)
|
||||
{
|
||||
return tr("获取登录信息失败!");
|
||||
}else
|
||||
{
|
||||
std::string instanceName = "BatchOperation";
|
||||
if(PERM_NORMAL != permMng->CurUser(m_userId, m_userGroupId, level, loginSec, instanceName))
|
||||
{
|
||||
m_userId = -1;
|
||||
return tr("获取登录账户失败!");
|
||||
}
|
||||
SSpeFuncDef speFunc;
|
||||
speFunc.location_id = location;
|
||||
speFunc.region_id = region;
|
||||
speFunc.func_define = "FUNC_SPE_OPT_CTRL";
|
||||
if (permMng->PermCheck(PERM_SPE_FUNC_DEF, &speFunc) == PERM_PERMIT)
|
||||
return "";
|
||||
else
|
||||
{
|
||||
QString mess = QString(tr("无标签操作权限!"));
|
||||
return mess;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tr("获取登录信息失败!");
|
||||
}
|
||||
void CBatchOperation::refreshData(int rowNum, bool res)
|
||||
{
|
||||
//获取对应的条目
|
||||
CBatchOperationModel *sourceModel = qobject_cast<CBatchOperationModel*>(filterModel->sourceModel());
|
||||
if( !sourceModel || rowNum > sourceModel->rowCount()) return;
|
||||
|
||||
QStandardItem *item = sourceModel->item(rowNum, 0);
|
||||
QModelIndex indexItem = sourceModel->index(rowNum , 0);
|
||||
item->setCheckable(true);
|
||||
QString resStr = res? tr("成功"):tr("失败");
|
||||
//sourceModel->setData( indexItem , resStr , Qt::TextColorRole);
|
||||
}
|
||||
|
||||
void CBatchOperation::slotUpdataRes(QMap<QString, QString> res)
|
||||
{
|
||||
if(res.isEmpty() || recordSendMess.isEmpty()) return;
|
||||
QMap<QString , QString>::iterator iter = res.begin();
|
||||
for( ; iter != res.end() ;iter++)
|
||||
{
|
||||
if( recordSendMess.contains(iter.key()) )
|
||||
{
|
||||
int rowNum = recordSendMess.value(iter.key());
|
||||
QString resStr = iter.value().isEmpty()?QString(tr("成功")):QString(tr("失败:%1").arg(iter.value()));
|
||||
CBatchOperationModel *sourceModel = qobject_cast<CBatchOperationModel*>(filterModel->sourceModel());
|
||||
sourceModel->refreshRow(rowNum , true , resStr);
|
||||
}
|
||||
}
|
||||
ui->tableView->update();
|
||||
|
||||
}
|
||||
|
||||
void CBatchOperation::showContextMenu(const QPoint &pos)
|
||||
{
|
||||
QModelIndex index = ui->tableView->indexAt(pos);
|
||||
int model = ui->m_typeCb->currentIndex();
|
||||
if (!index.isValid() || model <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
QMenu contextMenu;
|
||||
QAction *editAction = new QAction(tr("批量编辑"), this);
|
||||
connect(editAction, &QAction::triggered, [=]() { showDialog(model , index); });
|
||||
contextMenu.addAction(editAction);
|
||||
contextMenu.exec(ui->tableView->viewport()->mapToGlobal(pos));
|
||||
|
||||
}
|
||||
|
||||
void CBatchOperation::showDialog(int model, const QModelIndex &index)
|
||||
{
|
||||
QMap<int , QString> ctrOptions;
|
||||
ctrOptions.clear();
|
||||
CInputDialog dialog(model);
|
||||
if( model > EN_ANALOG )
|
||||
{
|
||||
QModelIndex sourceIndex = filterModel->mapToSource(index);
|
||||
ctrOptions = sourceIndex.model()->data(sourceIndex , Qt::UserRole + 11).value<QMap<int ,QString>>();
|
||||
int nextRow = index.row() + 1;
|
||||
while(ctrOptions.isEmpty())
|
||||
{
|
||||
if (nextRow >= filterModel->rowCount())
|
||||
{
|
||||
QMessageBox::warning(this , tr("警告") , tr("暂不能批量操作!"));
|
||||
return;
|
||||
}
|
||||
QModelIndex nextProxyIndex = ui->tableView->model()->index(nextRow, index.column());
|
||||
sourceIndex = filterModel->mapToSource(nextProxyIndex);
|
||||
ctrOptions = sourceIndex.model()->data(sourceIndex , Qt::UserRole + 11).value<QMap<int ,QString>>();
|
||||
nextRow ++;
|
||||
}
|
||||
dialog.setComBoxPara(ctrOptions);
|
||||
}
|
||||
if(QDialog::Accepted == dialog.exec() )
|
||||
{
|
||||
double value = dialog.getValue();
|
||||
setAllColumnValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
void CBatchOperation::slotOperationBtnClick()
|
||||
{
|
||||
int model = ui->m_typeCb->currentIndex();
|
||||
QModelIndex index = filterModel->index(0 ,2);
|
||||
if( index.isValid() )
|
||||
{
|
||||
showDialog(model , index);
|
||||
}else
|
||||
{
|
||||
QMessageBox::warning(this , tr("警告") , tr("暂不能批量操作!"));
|
||||
}
|
||||
}
|
||||
|
||||
void CBatchOperation::setAllColumnValue( double newValue)
|
||||
{
|
||||
// 获取源模型
|
||||
CBatchOperationModel *sourceModel = qobject_cast<CBatchOperationModel*>(filterModel->sourceModel());
|
||||
if (!sourceModel) return;
|
||||
int rowCount = filterModel->rowCount();
|
||||
|
||||
for (int row = 0; row < rowCount; ++row) {
|
||||
QModelIndex proxyIndex = filterModel->index(row, 2);
|
||||
QModelIndex sourceIndex = filterModel->mapToSource(proxyIndex);
|
||||
QStandardItem *item = sourceModel->item(sourceIndex.row(), 0);
|
||||
if (sourceIndex.isValid() && item && item->isCheckable() && item->checkState() == Qt::Checked) {
|
||||
sourceModel->setData(sourceIndex, newValue, Qt::EditRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
108
product/src/gui/plugin/BatchOperation/CBatchOperation.h
Normal file
108
product/src/gui/plugin/BatchOperation/CBatchOperation.h
Normal file
@ -0,0 +1,108 @@
|
||||
#ifndef CPCSBATCHOPERATION_H
|
||||
#define CPCSBATCHOPERATION_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVariantList>
|
||||
#include <QList>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QStandardItemModel>
|
||||
#include <QThread>
|
||||
#include <QPoint>
|
||||
|
||||
#include "dp_chg_data_api/CDpcdaForApp.h"
|
||||
#include "pub_sysinfo_api/SysInfoApi.h"
|
||||
#include "service/operate_server_api/JsonMessageStruct.h"
|
||||
#include "service/operate_server_api/JsonOptCommand.h"
|
||||
#include "CBatchOperationCollect.h"
|
||||
#include "BatchOperationComm.h"
|
||||
#include "CustonHeadView.h"
|
||||
#include "CBatchOperationModel.h"
|
||||
#include "CustomFilterModel.h"
|
||||
|
||||
namespace Ui {
|
||||
class CBatchOperation;
|
||||
}
|
||||
|
||||
class CBatchOperation : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CBatchOperation(QWidget *parent = 0 , bool editMode = true);
|
||||
~CBatchOperation();
|
||||
|
||||
int tableNameToEnum(const QString &tableName);
|
||||
|
||||
public slots:
|
||||
void setParaFromView( const int ®ionId , const QString &str);
|
||||
|
||||
void slotShowMess(const QString &mess);
|
||||
|
||||
signals:
|
||||
void updateData(const QStringList &strList);
|
||||
|
||||
void updateTableRow(int , bool);
|
||||
|
||||
void releaseCollectThread();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
||||
private:
|
||||
void initStyleSheet();
|
||||
|
||||
void initMsg();
|
||||
|
||||
void readNodeInfo(); //获取本机节点信息
|
||||
|
||||
void initialize();
|
||||
|
||||
QString permCheck(int locationId, int regionId);
|
||||
|
||||
int getAppIdByName(const QString &appName);
|
||||
|
||||
bool sendCtrTagInfo(bool isEnable);
|
||||
|
||||
QString checkPerm(int location, int region);
|
||||
|
||||
bool createReqHead(SOptReqHead &head, const STOptTagInfo &info);
|
||||
|
||||
bool OptTagInfo(const STOptTagInfo &info);
|
||||
|
||||
void setAllColumnValue( double newValue);
|
||||
|
||||
private slots:
|
||||
void brushTableView(const QStringList &strList);
|
||||
void slotExecuteBtnClick();
|
||||
void refreshData(int rowNum, bool res);
|
||||
void slotUpdataRes(QMap<QString , QString> res);
|
||||
void showContextMenu(const QPoint &pos);
|
||||
void showDialog(int model , const QModelIndex &index);
|
||||
void slotOperationBtnClick();
|
||||
|
||||
private:
|
||||
Ui::CBatchOperation *ui;
|
||||
|
||||
iot_public::CSysInfoInterfacePtr m_sysInfoPtr;
|
||||
iot_net::CMbCommunicator *m_communicator; //发送
|
||||
CBatchOperationCollect *m_BatchOpCollect; //接受信息订阅
|
||||
QThread *m_pCollectThread;
|
||||
iot_public::SNodeInfo m_nodeInfo; //本机节点信息
|
||||
|
||||
CBatchOperationModel *m_Model;
|
||||
QList<DataPoint> m_dataPoint;
|
||||
|
||||
|
||||
int m_regionId;
|
||||
|
||||
int m_userId;
|
||||
int m_userGroupId;
|
||||
|
||||
CustonHeadView *header; //自定义表头
|
||||
|
||||
CustomFilterModel *filterModel;//自定义过滤器
|
||||
|
||||
QMap<QString , int> recordSendMess;
|
||||
};
|
||||
|
||||
#endif // CPCSBATCHOPERATION_H
|
||||
139
product/src/gui/plugin/BatchOperation/CBatchOperation.ui
Normal file
139
product/src/gui/plugin/BatchOperation/CBatchOperation.ui
Normal file
@ -0,0 +1,139 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CBatchOperation</class>
|
||||
<widget class="QWidget" name="CBatchOperation">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1100</width>
|
||||
<height>552</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>测点类型</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="m_typeCb"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="opertionBtn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>批量操作</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="exebtn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>执行</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
134
product/src/gui/plugin/BatchOperation/CBatchOperationCollect.cpp
Normal file
134
product/src/gui/plugin/BatchOperation/CBatchOperationCollect.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
#include "CBatchOperationCollect.h"
|
||||
#include <QTimer>
|
||||
#include "pub_logger_api/logger.h"
|
||||
|
||||
CBatchOperationCollect::CBatchOperationCollect(/*int appID,*/QObject *parent):
|
||||
QObject(parent),
|
||||
m_pMbComm(NULL),
|
||||
m_pTimer(NULL),
|
||||
m_nTimeCount(0)
|
||||
{
|
||||
initMsg();
|
||||
if(!addSub(0, CH_OPT_TO_HMI_OPTCMD_UP))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_pTimer = new QTimer(this);
|
||||
connect(m_pTimer, SIGNAL(timeout()), this, SLOT(recvMessage()));
|
||||
m_pTimer->start(100);
|
||||
}
|
||||
|
||||
CBatchOperationCollect::~CBatchOperationCollect()
|
||||
{
|
||||
if(m_pTimer)
|
||||
{
|
||||
m_pTimer->stop();
|
||||
delete m_pTimer;
|
||||
}
|
||||
m_pTimer = NULL;
|
||||
|
||||
delSub(0, CH_OPT_TO_HMI_OPTCMD_UP);
|
||||
closeMsg();
|
||||
}
|
||||
|
||||
void CBatchOperationCollect::release()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
void CBatchOperationCollect::initMsg()
|
||||
{
|
||||
if(m_pMbComm == NULL)
|
||||
{
|
||||
m_pMbComm = new iot_net::CMbCommunicator("BatchOperation");
|
||||
}
|
||||
}
|
||||
void CBatchOperationCollect::closeMsg()
|
||||
{
|
||||
if(m_pMbComm != NULL)
|
||||
{
|
||||
delete m_pMbComm;
|
||||
}
|
||||
m_pMbComm = NULL;
|
||||
}
|
||||
|
||||
bool CBatchOperationCollect::addSub(int appID, int channel)
|
||||
{
|
||||
if(m_pMbComm)
|
||||
{
|
||||
return m_pMbComm->addSub(appID, channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CBatchOperationCollect::delSub(int appID, int channel)
|
||||
{
|
||||
if(m_pMbComm)
|
||||
{
|
||||
return m_pMbComm->delSub(appID, channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void CBatchOperationCollect::recvMessage()
|
||||
{
|
||||
m_nTimeCount = (m_nTimeCount + 1) % 36000;
|
||||
|
||||
if(m_nTimeCount % 10 == 0)
|
||||
{
|
||||
processChangeData();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
iot_net::CMbMessage objMsg;
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
if(m_pMbComm->recvMsg(objMsg, 0))
|
||||
{
|
||||
if(objMsg.isValid())
|
||||
{
|
||||
if(objMsg.getChannelID() == CH_OPT_TO_HMI_OPTCMD_UP
|
||||
&& objMsg.getMsgType() == MT_OPT_CTRL_UP_EXECUTE_REPLY)
|
||||
{
|
||||
std::string str((const char*)objMsg.getDataPtr(), objMsg.getDataSize());
|
||||
SOptCtrlReply socr;
|
||||
if(!COptCtrlReply::parse(str,socr))
|
||||
{
|
||||
return;
|
||||
}
|
||||
QString result = QString::fromStdString(str);
|
||||
if(socr.stHead.nIsSuccess==1)
|
||||
{
|
||||
m_controRes.insert(QString::fromStdString(socr.stHead.strKeyIdTag) , "");
|
||||
}else
|
||||
{
|
||||
m_controRes.insert(QString::fromStdString(socr.stHead.strKeyIdTag) , QString::fromStdString( socr.stHead.strResultStr ));
|
||||
}
|
||||
LOGERROR("deviceControl():命令执行结果:%s" , result.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
void CBatchOperationCollect::processChangeData()
|
||||
{
|
||||
if(!m_controRes.isEmpty())
|
||||
{
|
||||
LOGINFO("emit signal_updateRes dataList:%d",m_controRes.count());
|
||||
emit signal_updateRes(m_controRes);
|
||||
m_controRes.clear();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
#ifndef CBATCHOPERATIONCOLLECT_H
|
||||
#define CBATCHOPERATIONCOLLECT_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include "net_msg_bus_api/CMbCommunicator.h"
|
||||
#include "MessageChannel.h"
|
||||
#include "DataProcMessage.pb.h"
|
||||
#include "service/operate_server_api/JsonMessageStruct.h"
|
||||
#include "service/operate_server_api/JsonOptCommand.h"
|
||||
|
||||
class QTimer;
|
||||
class CBatchOperationCollect : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CBatchOperationCollect(/*int appID,*/QObject * parent = 0);
|
||||
~CBatchOperationCollect();
|
||||
|
||||
public slots:
|
||||
void release();
|
||||
|
||||
private:
|
||||
void initMsg();
|
||||
void closeMsg();
|
||||
bool addSub(int appID, int channel);
|
||||
bool delSub(int appID, int channel);
|
||||
|
||||
private slots:
|
||||
void recvMessage();
|
||||
void processChangeData();
|
||||
|
||||
signals:
|
||||
void signal_updateRes(QMap<QString, QString> controRes);
|
||||
|
||||
|
||||
private:
|
||||
iot_net::CMbCommunicator *m_pMbComm;
|
||||
QTimer * m_pTimer;
|
||||
int m_nTimeCount;
|
||||
QMap<QString, QString> m_controRes;
|
||||
};
|
||||
|
||||
#endif // CBATCHOPERATIONCOLLECT_H
|
||||
321
product/src/gui/plugin/BatchOperation/CBatchOperationModel.cpp
Normal file
321
product/src/gui/plugin/BatchOperation/CBatchOperationModel.cpp
Normal file
@ -0,0 +1,321 @@
|
||||
#include "CBatchOperationModel.h"
|
||||
|
||||
#include <QStandardItemModel>
|
||||
|
||||
CBatchOperationModel::CBatchOperationModel(QObject *parent)
|
||||
: QStandardItemModel(parent)
|
||||
{
|
||||
m_header<<tr("测点信息")<<tr("当前值")<<tr("控制操作")<<tr("执行结果");
|
||||
}
|
||||
|
||||
QVariant CBatchOperationModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if( role == Qt::DisplayRole)
|
||||
{
|
||||
if(orientation == Qt::Horizontal && section < m_header.size())
|
||||
{
|
||||
return m_header.at(section);
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant CBatchOperationModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid()|| index.row() >= m_dataList.size())
|
||||
return QVariant();
|
||||
|
||||
if(role == Qt::TextAlignmentRole)
|
||||
{
|
||||
return Qt::AlignCenter;
|
||||
}
|
||||
|
||||
QModelIndex sourceIndex = index;
|
||||
|
||||
|
||||
const DataPoint &item = m_dataList.at(sourceIndex.row());
|
||||
|
||||
if ( !item.isEnableContro && role == Qt::ForegroundRole) {
|
||||
return QBrush(QColor(169, 169, 169));
|
||||
}
|
||||
else if (role == Qt::ForegroundRole) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
if (role == Qt::CheckStateRole && sourceIndex.column() == 0 )
|
||||
{
|
||||
return this->item(sourceIndex.row(), 0)->checkState();
|
||||
}
|
||||
else if (role == Qt::UserRole + 1)
|
||||
{
|
||||
return item.keyTag;
|
||||
}
|
||||
else if (role == Qt::UserRole + 2)
|
||||
{
|
||||
return item.pointTag;
|
||||
}
|
||||
else if (role == Qt::UserRole + 3)
|
||||
{
|
||||
return item.tableName;
|
||||
}
|
||||
else if (role == Qt::UserRole + 4)
|
||||
{
|
||||
return item.tagDesc;
|
||||
}
|
||||
else if (role == Qt::UserRole + 5)
|
||||
{
|
||||
return item.tableDesc;
|
||||
}
|
||||
else if (role == Qt::UserRole + 6)
|
||||
{
|
||||
return item.dataType;
|
||||
}
|
||||
else if (role == Qt::UserRole + 7)
|
||||
{
|
||||
return item.appId;
|
||||
}
|
||||
else if (role == Qt::UserRole + 8)
|
||||
{
|
||||
return item.locationId;
|
||||
}
|
||||
else if (role == Qt::UserRole + 9)
|
||||
{
|
||||
return item.domainId;
|
||||
}else if (role == Qt::UserRole + 10)
|
||||
{
|
||||
return item.region;
|
||||
}else if (role == Qt::UserRole + 11)
|
||||
{
|
||||
return QVariant::fromValue(item.controlOpt);
|
||||
}else if (role == Qt::UserRole + 12)
|
||||
{
|
||||
return item.setValue;
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole) {
|
||||
switch (sourceIndex.column()) {
|
||||
case 0:
|
||||
{
|
||||
return item.tableDesc + " " +item.tagDesc + item.unit;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if(item.dataType == EN_ANALOG)
|
||||
{
|
||||
return QString::number(item.value_ai, 'f', 2);
|
||||
}
|
||||
else if(item.dataType == EN_DIGITAL)
|
||||
{
|
||||
return CDbInterface::instance()->getStateTextNameByValue(item.stateTextName, item.value_di);
|
||||
}
|
||||
else if(item.dataType == EN_ACCUML)
|
||||
{
|
||||
return QString::number(item.value_pi, 'f', 2);
|
||||
}
|
||||
else if(item.dataType == EN_MIX)
|
||||
{
|
||||
return CDbInterface::instance()->getStateTextNameByValue(item.stateTextName, item.value_mi);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
if(item.dataType == EN_DIGITAL || item.dataType == EN_MIX)
|
||||
{
|
||||
return item.controlOpt.isEmpty()?QString(""):item.controlOpt.value(item.setValue , item.controlOpt.first());
|
||||
}else
|
||||
{
|
||||
return item.setValue;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
return item.resText;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool CBatchOperationModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (!index.isValid() || index.row() >= rowCount() || index.column() >= columnCount())
|
||||
return false;
|
||||
|
||||
int type = index.model()->data(index, Qt::UserRole + 6).toInt();
|
||||
|
||||
QModelIndex sourceIndex = index;
|
||||
|
||||
if (sourceIndex.column() == 0 && role == Qt::CheckStateRole) {
|
||||
QStandardItem *item = this->item(sourceIndex.row(), 0); // 获取第一列的项 item
|
||||
if (item) {
|
||||
item->setCheckState(static_cast<Qt::CheckState>(value.toInt())); // 设置复选框的状态
|
||||
emit dataChanged(sourceIndex, sourceIndex, {role});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (role == Qt::EditRole ) {
|
||||
if( sourceIndex.column() == 0)
|
||||
{
|
||||
m_dataList[sourceIndex.row()].isEnableContro = value.toBool();
|
||||
emit dataChanged(sourceIndex, sourceIndex, {Qt::DisplayRole});
|
||||
return true;
|
||||
}
|
||||
if( sourceIndex.column() == 2 )
|
||||
{
|
||||
if( EN_DIGITAL == type || EN_MIX == type)
|
||||
{
|
||||
if( !m_dataList[sourceIndex.row()].controlOpt.contains(value.toInt()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
m_dataList[sourceIndex.row()].setValue = value.toDouble();
|
||||
emit dataChanged(sourceIndex, sourceIndex, {Qt::DisplayRole});
|
||||
return true;
|
||||
}else if( sourceIndex.column() == 3)
|
||||
{
|
||||
m_dataList[sourceIndex.row()].resText = value.toString();
|
||||
emit dataChanged(sourceIndex, sourceIndex, {Qt::DisplayRole});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if( sourceIndex.column() == 1)
|
||||
{
|
||||
if( role == Qt::UserRole + 1)
|
||||
{
|
||||
m_dataList[sourceIndex.row()].value_ai = value.toFloat();
|
||||
}
|
||||
else if( role == Qt::UserRole + 2)
|
||||
{
|
||||
m_dataList[sourceIndex.row()].value_pi = value.toDouble();
|
||||
}
|
||||
else if( role == Qt::UserRole + 3)
|
||||
{
|
||||
m_dataList[sourceIndex.row()].value_di = value.toInt();
|
||||
}
|
||||
else if( role == Qt::UserRole + 4)
|
||||
{
|
||||
m_dataList[sourceIndex.row()].value_mi = value.toInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::ItemFlags CBatchOperationModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return Qt::NoItemFlags;
|
||||
|
||||
|
||||
QModelIndex sourceIndex = index;
|
||||
Qt::ItemFlags defaultFlags = QStandardItemModel::flags(sourceIndex);
|
||||
|
||||
if (sourceIndex.column() == 0)
|
||||
{
|
||||
const DataPoint &item = m_dataList.at(sourceIndex.row());
|
||||
if (item.isEnableContro) {
|
||||
return Qt::ItemIsUserCheckable | defaultFlags;
|
||||
} else {
|
||||
return defaultFlags & ~Qt::ItemIsEnabled & ~Qt::ItemIsUserCheckable;
|
||||
}
|
||||
}
|
||||
|
||||
if( sourceIndex.column() == 1 || sourceIndex.column() == 3)
|
||||
{
|
||||
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | defaultFlags;
|
||||
}
|
||||
|
||||
return defaultFlags;
|
||||
}
|
||||
|
||||
|
||||
void CBatchOperationModel::updateDataPoint(QList<DataPoint> &dataList)
|
||||
{
|
||||
beginResetModel();
|
||||
m_dataList = dataList;
|
||||
populateModel();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void CBatchOperationModel::refreshRow(int rowNum, bool checkState, QString controStr)
|
||||
{
|
||||
if( rowNum < 0 || rowNum >= m_dataList.size() ) return;
|
||||
|
||||
m_dataList[rowNum].isEnableContro = checkState;
|
||||
m_dataList[rowNum].resText = controStr;
|
||||
|
||||
int appid = m_dataList[rowNum].appId;
|
||||
QString tableName = m_dataList[rowNum].tableName;
|
||||
QString point = m_dataList[rowNum].pointTag;
|
||||
int domainid = m_dataList[rowNum].domainId;
|
||||
int type = m_dataList[rowNum].dataType;
|
||||
QVariantList list = CDbInterface::instance()->rdbNetGetByKey(appid , tableName , point , "value" , domainid);
|
||||
if(list.size() >= 2)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EN_ANALOG:
|
||||
m_dataList[rowNum].value_ai = list[1].toFloat();
|
||||
break;
|
||||
case EN_ACCUML:
|
||||
m_dataList[rowNum].value_pi = list[1].toDouble();
|
||||
break;
|
||||
case EN_DIGITAL:
|
||||
m_dataList[rowNum].value_di = list[1].toInt();
|
||||
break;
|
||||
case EN_MIX:
|
||||
m_dataList[rowNum].value_mi = list[1].toInt();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
QStandardItem *item = this->item(rowNum, 0);
|
||||
if (item && !checkState)
|
||||
{
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
|
||||
|
||||
|
||||
emit dataChanged(index(rowNum, 0), index(rowNum, columnCount() - 1));
|
||||
|
||||
}
|
||||
|
||||
void CBatchOperationModel::populateModel()
|
||||
{
|
||||
clear(); // 清空模型
|
||||
setColumnCount(4); // 设置列数
|
||||
|
||||
for (const DataPoint &item : m_dataList) {
|
||||
QList<QStandardItem *> items;
|
||||
QStandardItem * itemHead = new QStandardItem("");
|
||||
itemHead->setCheckable(item.isEnableContro?true:false);
|
||||
items.append(itemHead);
|
||||
items.append(new QStandardItem(""));
|
||||
items.append(new QStandardItem(""));
|
||||
items.append(new QStandardItem(""));
|
||||
appendRow(items);
|
||||
}
|
||||
}
|
||||
|
||||
void CBatchOperationModel::setAllChecked(bool checked)
|
||||
{
|
||||
Qt::CheckState state = checked ? Qt::Checked : Qt::Unchecked;
|
||||
for (int row = 0; row < rowCount(); ++row) {
|
||||
QModelIndex index = this->index(row, 0);
|
||||
if (flags(index) & Qt::ItemIsUserCheckable) {
|
||||
setData(index, state, Qt::CheckStateRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
39
product/src/gui/plugin/BatchOperation/CBatchOperationModel.h
Normal file
39
product/src/gui/plugin/BatchOperation/CBatchOperationModel.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef CBATCHOPERATIONMODEL_H
|
||||
#define CBATCHOPERATIONMODEL_H
|
||||
|
||||
#include <QStandardItemModel>
|
||||
#include <QList>
|
||||
#include "BatchOperationComm.h"
|
||||
#include "CDbInterface.h"
|
||||
#include <QtWidgets/QTableView>
|
||||
|
||||
class CBatchOperationModel : public QStandardItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CBatchOperationModel(QObject *parent = nullptr);
|
||||
|
||||
// Header:
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value,
|
||||
int role = Qt::EditRole) override;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
void updateDataPoint(QList<DataPoint> &dataList);
|
||||
void refreshRow(int rowNum , bool checkState , QString controStr);
|
||||
|
||||
private:
|
||||
void populateModel();
|
||||
|
||||
public slots:
|
||||
void setAllChecked(bool checked);
|
||||
|
||||
private:
|
||||
QStringList m_header;
|
||||
QList<DataPoint> m_dataList;
|
||||
};
|
||||
|
||||
#endif // CBATCHOPERATIONMODEL_H
|
||||
806
product/src/gui/plugin/BatchOperation/CDbInterface.cpp
Normal file
806
product/src/gui/plugin/BatchOperation/CDbInterface.cpp
Normal file
@ -0,0 +1,806 @@
|
||||
#include "CDbInterface.h"
|
||||
#include "service/perm_mng_api/PermMngApi.h"
|
||||
#include "pub_logger_api/logger.h"
|
||||
#include "../../idl_files/Public.pb.h"
|
||||
#include <QDebug>
|
||||
#include "BatchOperationComm.h"
|
||||
|
||||
using namespace iot_dbms;
|
||||
using namespace iot_public;
|
||||
using namespace iot_idl;
|
||||
|
||||
CDbInterface *CDbInterface::m_pInstance = NULL;
|
||||
|
||||
CDbInterface::CDbInterface()
|
||||
{
|
||||
m_pReadDb = new CDbApi(DB_CONN_MODEL_READ);
|
||||
m_pReadDb->open();
|
||||
|
||||
m_rtdbAccess = new iot_dbms::CRdbAccess();
|
||||
m_rdbNetAccess = new iot_dbms::CRdbNetApi();
|
||||
|
||||
readUnitInfo();
|
||||
readDiStatus();
|
||||
readAiStatus();
|
||||
loadRTLocation();
|
||||
loadDeviceInfo();
|
||||
}
|
||||
|
||||
CDbInterface *CDbInterface::instance()
|
||||
{
|
||||
if(NULL == m_pInstance)
|
||||
{
|
||||
m_pInstance = new CDbInterface();
|
||||
}
|
||||
return m_pInstance;
|
||||
}
|
||||
|
||||
void CDbInterface::destory()
|
||||
{
|
||||
if(m_pReadDb)
|
||||
{
|
||||
m_pReadDb->close();
|
||||
delete m_pReadDb;
|
||||
}
|
||||
m_pReadDb = NULL;
|
||||
|
||||
if(m_rtdbAccess != NULL)
|
||||
{
|
||||
delete m_rtdbAccess;
|
||||
}
|
||||
m_rtdbAccess = NULL;
|
||||
|
||||
if(m_rdbNetAccess != NULL)
|
||||
{
|
||||
delete m_rdbNetAccess;
|
||||
}
|
||||
m_rdbNetAccess = NULL;
|
||||
|
||||
m_mapUnit.clear();
|
||||
m_mapAiStatus.clear();
|
||||
m_mapDiStatus.clear();
|
||||
m_pInstance = NULL;
|
||||
delete this;
|
||||
}
|
||||
|
||||
QMap<int, QString> CDbInterface::locationInfo()
|
||||
{
|
||||
return m_locationInfo;
|
||||
}
|
||||
|
||||
QString CDbInterface::getLocationDesc(const int &locId)
|
||||
{
|
||||
return m_locationInfo.value(locId);
|
||||
}
|
||||
|
||||
QList<int> CDbInterface::getLocationOrder()
|
||||
{
|
||||
return m_locOrder;
|
||||
}
|
||||
|
||||
bool CDbInterface::queryDevGroupInfoList(const int &nLocId, const int &nSubId, QList<QPair<QString, QString> > &devgList)
|
||||
{
|
||||
if(nLocId == CN_InvalidLocationId)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
QSqlQuery query;
|
||||
QString sqlSequenceQuery;
|
||||
if(nSubId == CN_InvalidSubsystemId)
|
||||
{
|
||||
//< 所有专业
|
||||
sqlSequenceQuery = QString("select tag_name, description from dev_group where location_id = %1 order by dev_group_no asc; ")
|
||||
.arg(nLocId);
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlSequenceQuery = QString("select tag_name, description from dev_group where location_id = %1 and sub_system = %2 order by dev_group_no asc; ")
|
||||
.arg(nLocId).arg(nSubId);
|
||||
}
|
||||
if(!m_pReadDb->execute(sqlSequenceQuery, query))
|
||||
{
|
||||
LOGINFO("查找位置[%d],专业[%d]下的设备组失败!",nLocId,nSubId);
|
||||
return false;
|
||||
}
|
||||
while(query.next())
|
||||
{
|
||||
QPair<QString, QString> pair;
|
||||
pair.first = query.value(0).toString();
|
||||
pair.second = query.value(1).toString();
|
||||
devgList.append(pair);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QMap<QString, QString> CDbInterface::deviceInfo(const QString &devGroupName)
|
||||
{
|
||||
return m_devGDevInfoMap.value(devGroupName, QMap<QString, QString>());
|
||||
}
|
||||
|
||||
QList<QString> CDbInterface::deviceInfoByDevg(const QString &devGroupName)
|
||||
{
|
||||
return m_devGDevInfoMap.value(devGroupName, QMap<QString, QString>()).keys();
|
||||
}
|
||||
|
||||
QMap<QString, QString> CDbInterface::readDevGroupDesc(const QStringList &tagList)
|
||||
{
|
||||
QMap<QString, QString> map;
|
||||
if(tagList.isEmpty())
|
||||
{
|
||||
return map;
|
||||
}
|
||||
if(!m_pReadDb->isOpen())
|
||||
{
|
||||
return map;
|
||||
}
|
||||
QSqlQuery query;
|
||||
QString str = tagList.join("','");
|
||||
QString sqlQuery = QString("select TAG_NAME,DESCRIPTION from dev_group where TAG_NAME in ('%1')").arg(str);
|
||||
m_pReadDb->execute(sqlQuery, query);
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
QString tag = query.value(0).toString();
|
||||
QString desc = query.value(1).toString();
|
||||
|
||||
map.insert(tag, desc);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
QMap<QString , QString> CDbInterface::searchPointInfo(const QStringList &dataList)
|
||||
{
|
||||
if( dataList.isEmpty()) {return QMap<QString , QString>();}
|
||||
if(!m_pReadDb->isOpen())
|
||||
{
|
||||
return QMap<QString, QString>();
|
||||
}
|
||||
|
||||
QMap<QString , QString > res;
|
||||
res.clear();
|
||||
|
||||
|
||||
QSqlQuery query;
|
||||
QStringList queries;
|
||||
|
||||
foreach (QString var, dataList)
|
||||
{
|
||||
int count = var.count(".");
|
||||
QString tagName = var.section('.', 3, count - 1);
|
||||
QString tableName = var.section('.', 2, 2);
|
||||
QString add = QString();
|
||||
QString joinStr = QString();
|
||||
QString add2 = QString();
|
||||
if(tableName == "analog" || tableName == "accuml")
|
||||
{
|
||||
add = ",t1.UNIT_ID";
|
||||
add2 = ", NULL AS CTRL_ACT_NAME";
|
||||
}
|
||||
else if( tableName == "mix" )
|
||||
{
|
||||
add = ",t1.STATE_TEXT_NAME";
|
||||
add2 = ", t4.CTRL_ACT_NAME";
|
||||
joinStr = "LEFT JOIN mix_control as t4 ON t1.TAG_NAME = t4.TAG_NAME ";
|
||||
|
||||
}else if ( tableName == "digital" )
|
||||
{
|
||||
add = ",t1.STATE_TEXT_NAME";
|
||||
add2 = ", t4.CTRL_ACT_NAME";
|
||||
joinStr = "LEFT JOIN digital_control as t4 ON t1.TAG_NAME = t4.TAG_NAME ";
|
||||
}
|
||||
QString sqlQuery = QString(
|
||||
"SELECT t1.TAG_NAME, t1.DESCRIPTION,t3.DESCRIPTION%1, t1.REGION_ID, t1.LOCATION_ID ,'%2' AS table_name%3 "
|
||||
"FROM %4 as t1 "
|
||||
"LEFT JOIN dev_info as t2 ON t1.DEVICE = t2.TAG_NAME "
|
||||
"LEFT JOIN dev_group as t3 ON t2.GROUP_TAG_NAME = t3.TAG_NAME "
|
||||
"%5"
|
||||
"WHERE t1.TAG_NAME = '%6'")
|
||||
.arg(add)
|
||||
.arg(tableName)
|
||||
.arg(add2)
|
||||
.arg(tableName)
|
||||
.arg(joinStr)
|
||||
.arg(tagName);
|
||||
//qDebug()<<sqlQuery;
|
||||
queries.append(sqlQuery);
|
||||
}
|
||||
QString finalQuery = queries.join(" UNION ALL ");
|
||||
m_pReadDb->execute(finalQuery, query);
|
||||
//qDebug()<<finalQuery;
|
||||
while( query.next())
|
||||
{
|
||||
QString tag = query.value(0).toString();
|
||||
QString descPoint = query.value(1).toString();
|
||||
QString devDesc = query.value(2).toString();
|
||||
int region = query.value(4).toInt();
|
||||
int location = query.value(5).toInt();
|
||||
QString tableName = query.value(6).toString();
|
||||
QString value;
|
||||
if(tableName == "analog" || tableName == "accuml")
|
||||
{
|
||||
QString unitName = getUnitName(query.value(3).toInt());
|
||||
QString unit = QString();
|
||||
if(unitName != " ")
|
||||
unit = " (" + unitName + ")";
|
||||
|
||||
value = QString("%1,%2,%3,%4,%5").arg(descPoint).arg(devDesc).arg(unit).arg(region).arg(location);
|
||||
}
|
||||
else if(tableName == "digital" || tableName == "mix")
|
||||
{
|
||||
QString stateTextName = query.value(3).toString();
|
||||
QString controlTextName = query.value(7).toString();
|
||||
value = QString("%1,%2,%3,%4,%5,%6").arg(descPoint).arg(devDesc).arg(stateTextName).arg(region).arg(location).arg(controlTextName);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = QString("%1,%2,%3,%4,%5").arg(descPoint).arg(devDesc).arg("").arg(region).arg(location);
|
||||
}
|
||||
res.insert(tag , value);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
QMap<QString, QMap<QString, QString> > CDbInterface::readPointInfo(const QStringList &strDev, const QStringList &listTableName)
|
||||
{
|
||||
if(strDev.isEmpty())
|
||||
{
|
||||
return QMap<QString, QMap<QString,QString>>();
|
||||
}
|
||||
|
||||
QMap<QString, QMap<QString, QString>> map;
|
||||
for(int nIndex=0; nIndex<listTableName.length(); ++nIndex)
|
||||
{
|
||||
QString tableName = listTableName.at(nIndex);
|
||||
QMap<QString, QString> ret = readPointInfo(strDev, tableName);
|
||||
if(!ret.isEmpty())
|
||||
{
|
||||
map.insert(tableName, ret);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
QMap<QString, QString> CDbInterface::readPointInfo(const QStringList &strDev, const QString &strTableName)
|
||||
{
|
||||
if(strDev.isEmpty())
|
||||
{
|
||||
return QMap<QString, QString>();
|
||||
}
|
||||
if(!m_pReadDb->isOpen())
|
||||
{
|
||||
return QMap<QString, QString>();
|
||||
}
|
||||
|
||||
QMap<QString, QString> map;
|
||||
QSqlQuery query;
|
||||
QString addQuery;
|
||||
for(int nIndex = 0; nIndex < strDev.length(); ++nIndex)
|
||||
{
|
||||
addQuery += "'" + strDev[nIndex] + "'";
|
||||
if(nIndex != strDev.length() - 1)
|
||||
{
|
||||
addQuery += ",";
|
||||
}
|
||||
}
|
||||
|
||||
QString add = QString();
|
||||
if(strTableName == "analog" || strTableName == "accuml")
|
||||
{
|
||||
add = ",t1.UNIT_ID";
|
||||
}
|
||||
else if(strTableName == "digital" || strTableName == "mix")
|
||||
{
|
||||
add = ",t1.STATE_TEXT_NAME";
|
||||
}
|
||||
QString sqlQuery = QString("select t1.TAG_NAME,t1.DESCRIPTION,t1.SEQ_NO,t2.DESCRIPTION%1,t1.REGION_ID,t1.LOCATION_ID,t1.SUB_SYSTEM from %2 as t1 left join dev_info as t2 on t1.DEVICE = t2.TAG_NAME where t1.DEVICE in (%3)").arg(add).arg(strTableName).arg(addQuery);
|
||||
m_pReadDb->execute(sqlQuery, query);
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
QString tag = query.value(0).toString();
|
||||
QString desc = query.value(1).toString();
|
||||
int seq = query.value(2).toInt();
|
||||
QString dev = query.value(3).toString();
|
||||
int region = query.value(5).toInt();
|
||||
int location = query.value(6).toInt();
|
||||
int subSystem = query.value(7).toInt();
|
||||
QString value;
|
||||
if(strTableName == "analog" || strTableName == "accuml")
|
||||
{
|
||||
QString unitName = getUnitName(query.value(4).toInt());
|
||||
QString unit = QString();
|
||||
if(unitName != " ")
|
||||
unit = " (" + unitName + ")";
|
||||
|
||||
value = QString("%1,%2,%3,%4,%5,%6,%7").arg(desc).arg(dev).arg(seq).arg(unit).arg(region).arg(location).arg(subSystem);
|
||||
}
|
||||
else if(strTableName == "digital" || strTableName == "mix")
|
||||
{
|
||||
QString stateTextName = query.value(4).toString();
|
||||
value = QString("%1,%2,%3,%4,%5,%6,%7").arg(desc).arg(dev).arg(seq).arg(stateTextName).arg(region).arg(location).arg(subSystem);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = QString("%1,%2,%3,%4,%5,%6,%7").arg(desc).arg(dev).arg(seq).arg("").arg(region).arg(location).arg(subSystem);
|
||||
}
|
||||
|
||||
map.insert(tag, value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
QString CDbInterface::getUnitName(int unitId)
|
||||
{
|
||||
QMap<int, QString>::const_iterator iter = m_mapUnit.find(unitId);
|
||||
if(iter != m_mapUnit.constEnd())
|
||||
{
|
||||
return iter.value();
|
||||
}
|
||||
return " ";
|
||||
}
|
||||
|
||||
QString CDbInterface::getStateTextNameByValue(const QString &textName, int value)
|
||||
{
|
||||
QString ret = QString::number(value);
|
||||
if(m_rtdbAccess->open("base", "dict_state_text_info"))
|
||||
{
|
||||
CONDINFO condition1;
|
||||
memcpy(condition1.name, "state_text_name", strlen("state_text_name"));
|
||||
condition1.logicalop = ATTRCOND_AND;
|
||||
condition1.relationop = ATTRCOND_EQU;
|
||||
condition1.conditionval = textName.toStdString().c_str();
|
||||
|
||||
CONDINFO condition2;
|
||||
memcpy(condition2.name, "actual_value", strlen("actual_value"));
|
||||
condition2.logicalop = ATTRCOND_AND;
|
||||
condition2.relationop = ATTRCOND_EQU;
|
||||
condition2.conditionval = value;
|
||||
|
||||
std::vector<CONDINFO> vecCondInfo;
|
||||
vecCondInfo.push_back(condition1);
|
||||
vecCondInfo.push_back(condition2);
|
||||
|
||||
CRdbQueryResult result;
|
||||
std::vector<std::string> columns;
|
||||
columns.push_back("display_value");
|
||||
if(m_rtdbAccess->select(vecCondInfo, result, columns))
|
||||
{
|
||||
for(int nIndex(0); nIndex < result.getRecordCount(); nIndex++)
|
||||
{
|
||||
CVarType value;
|
||||
result.getColumnValue(nIndex, 0, value);
|
||||
ret = QString::fromStdString(value.toStdString());
|
||||
}
|
||||
}
|
||||
m_rtdbAccess->close();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CDbInterface::getStateTextList(const QString &textName, QMap<int, QString>& textMap)
|
||||
{
|
||||
if (m_rtdbAccess->open("base", "dict_state_text_info"))
|
||||
{
|
||||
CONDINFO condition1;
|
||||
memcpy(condition1.name, "state_text_name", strlen("state_text_name"));
|
||||
condition1.logicalop = ATTRCOND_AND;
|
||||
condition1.relationop = ATTRCOND_EQU;
|
||||
condition1.conditionval = textName.toStdString().c_str();
|
||||
|
||||
std::vector<CONDINFO> vecCondInfo;
|
||||
vecCondInfo.push_back(condition1);
|
||||
|
||||
CRdbQueryResult result;
|
||||
std::vector<std::string> columns;
|
||||
columns.push_back("state_text_name");
|
||||
columns.push_back("actual_value");
|
||||
columns.push_back("display_value");
|
||||
|
||||
if (m_rtdbAccess->select(vecCondInfo, result, columns))
|
||||
{
|
||||
for (int nIndex(0); nIndex < result.getRecordCount(); nIndex++)
|
||||
{
|
||||
CVarType value;
|
||||
result.getColumnValue(nIndex, 1, value);
|
||||
int realValue = value.toInt();
|
||||
result.getColumnValue(nIndex, 2, value);
|
||||
QString display_value = QString::fromStdString(value.toStdString());
|
||||
textMap[realValue] = display_value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
m_rtdbAccess->close();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDbInterface::getControlList(const QString &textName, QMap<int, QString>& textMap)
|
||||
{
|
||||
if( m_pReadDb->isOpen())
|
||||
{
|
||||
QSqlQuery query;
|
||||
QString sqlQuery = QString(
|
||||
"SELECT CTRL_ACT_TYPE , CTRL_ACT_NAME "
|
||||
"FROM opt_ctrl_act_define "
|
||||
"WHERE CTRL_GRP_NAME = '%1'")
|
||||
.arg(textName);
|
||||
m_pReadDb->execute(sqlQuery, query);
|
||||
|
||||
while (query.next())
|
||||
{
|
||||
int seqNo = query.value(0).toInt();
|
||||
QString name = query.value(1).toString();
|
||||
textMap.insert(seqNo , name);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString CDbInterface::getStatusStr(int status, int table)
|
||||
{
|
||||
QString ret = QString();
|
||||
int num = 0;
|
||||
int temp = status;
|
||||
while(temp != 0)
|
||||
{
|
||||
if((temp % 2) == 1)
|
||||
{
|
||||
if(table == EN_ANALOG || table == EN_ACCUML || table == EN_MIX)
|
||||
ret += getAiStatusStr(num);
|
||||
else if(table == EN_DIGITAL)
|
||||
ret += getDiStatusStr(num);
|
||||
ret += " ";
|
||||
}
|
||||
temp /= 2;
|
||||
num += 1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString CDbInterface::getPointDesc(int point_type)
|
||||
{
|
||||
QString ret = QString::number(point_type);
|
||||
switch (point_type) {
|
||||
case EN_ANALOG:
|
||||
{
|
||||
ret = QObject::tr("模拟量");
|
||||
break;
|
||||
}
|
||||
case EN_DIGITAL:
|
||||
{
|
||||
ret = QObject::tr("数字量");
|
||||
break;
|
||||
}
|
||||
case EN_ACCUML:
|
||||
{
|
||||
ret = QObject::tr("累积量");
|
||||
break;
|
||||
}
|
||||
case EN_MIX:
|
||||
{
|
||||
ret = QObject::tr("混合量");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CDbInterface::isAlarmEnable(int status, int table)
|
||||
{
|
||||
|
||||
if (table == EN_ANALOG || table == EN_ACCUML || table == EN_MIX)
|
||||
{
|
||||
return isBitEnable(status, 21);
|
||||
}
|
||||
|
||||
else if (table == EN_DIGITAL)
|
||||
{
|
||||
return isBitEnable(status, 13);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDbInterface::isCtrlEnable(int status, int table)
|
||||
{
|
||||
if (table == EN_ANALOG || table == EN_ACCUML || table == EN_MIX)
|
||||
{
|
||||
return isBitEnable(status, 22);
|
||||
}
|
||||
|
||||
else if (table == EN_DIGITAL)
|
||||
{
|
||||
return isBitEnable(status, 14);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDbInterface::isRefreshEnable(int status, int table)
|
||||
{
|
||||
if (table == EN_ANALOG || table == EN_ACCUML || table == EN_MIX)
|
||||
{
|
||||
return isBitEnable(status, 20);
|
||||
}
|
||||
|
||||
else if (table == EN_DIGITAL)
|
||||
{
|
||||
return isBitEnable(status, 12);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDbInterface::isSetValueEnable(int status, int table)
|
||||
{
|
||||
if (table == EN_ANALOG || table == EN_ACCUML || table == EN_MIX)
|
||||
{
|
||||
return isBitEnable(status, 10);
|
||||
}
|
||||
|
||||
else if (table == EN_DIGITAL)
|
||||
{
|
||||
return isBitEnable(status, 11);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDbInterface::isBitEnable(int status, int checkNum)
|
||||
{
|
||||
return ((status >> (checkNum)) & 0x01) == 0x01;
|
||||
}
|
||||
|
||||
QString CDbInterface::getDiStatusStr(int status)
|
||||
{
|
||||
QMap<int, QString>::const_iterator iter = m_mapDiStatus.find(status);
|
||||
if(iter != m_mapDiStatus.constEnd())
|
||||
{
|
||||
return iter.value();
|
||||
}
|
||||
return " ";
|
||||
}
|
||||
|
||||
QString CDbInterface::getAiStatusStr(int status)
|
||||
{
|
||||
QMap<int, QString>::const_iterator iter = m_mapAiStatus.find(status);
|
||||
if(iter != m_mapAiStatus.constEnd())
|
||||
{
|
||||
return iter.value();
|
||||
}
|
||||
return " ";
|
||||
}
|
||||
|
||||
void CDbInterface::loadRTLocation()
|
||||
{
|
||||
iot_service::CPermMngApiPtr permMngPtr = iot_service::getPermMngInstance("base");
|
||||
if(permMngPtr == NULL || (PERM_NORMAL != permMngPtr->PermDllInit()))
|
||||
{
|
||||
LOGERROR("权限接口初始化失败!");
|
||||
return;
|
||||
}
|
||||
int level;
|
||||
std::vector <int> vecLocationId;
|
||||
std::vector<std::string> vecPermPic;
|
||||
if (PERM_NORMAL != permMngPtr->GetUsergInfo(level, vecLocationId, vecPermPic))
|
||||
{
|
||||
LOGERROR("权限接口获取获取当前登录用户组的等级、所属车站ID失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string strApplicationName = "base";
|
||||
std::string strTableName = "sys_model_location_info";
|
||||
QPair<std::string, std::string> id_value;
|
||||
id_value.first = "location_id";
|
||||
id_value.second = "description";
|
||||
if(m_rtdbAccess->open(strApplicationName.c_str(), strTableName.c_str()))
|
||||
{
|
||||
iot_dbms::CTableLockGuard locker(*m_rtdbAccess);
|
||||
iot_dbms::CRdbQueryResult result;
|
||||
std::vector<std::string> columns;
|
||||
columns.push_back(id_value.first);
|
||||
columns.push_back(id_value.second);
|
||||
std::string sOrderColumn = "location_no";
|
||||
|
||||
if(m_rtdbAccess->select(result, columns, sOrderColumn))
|
||||
{
|
||||
m_locationInfo.clear();
|
||||
for(int nIndex(0); nIndex < result.getRecordCount(); nIndex++)
|
||||
{
|
||||
iot_dbms::CVarType key;
|
||||
iot_dbms::CVarType value;
|
||||
result.getColumnValue(nIndex, 0, key);
|
||||
result.getColumnValue(nIndex, 1, value);
|
||||
|
||||
std::vector <int>::const_iterator it = vecLocationId.cbegin();
|
||||
while (it != vecLocationId.cend())
|
||||
{
|
||||
if(key.toInt() == *it)
|
||||
{
|
||||
m_locationInfo[key.toInt()] = QString::fromStdString(value.toStdString());
|
||||
m_locOrder.push_back(key.toInt());
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_rtdbAccess->close();
|
||||
}
|
||||
|
||||
void CDbInterface::loadDeviceInfo()
|
||||
{
|
||||
if(!m_pReadDb->isOpen())
|
||||
{
|
||||
return ;
|
||||
}
|
||||
QSqlQuery query;
|
||||
QString sqlQuery = QString("select TAG_NAME,DESCRIPTION,GROUP_TAG_NAME from dev_info");
|
||||
|
||||
m_pReadDb->execute(sqlQuery, query);
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
QString tag = query.value(0).toString();
|
||||
QString desc = query.value(1).toString();
|
||||
QString devg = query.value(2).toString();
|
||||
QMap<QString, QMap<QString,QString > >::iterator iter = m_devGDevInfoMap.find(devg);
|
||||
if(iter != m_devGDevInfoMap.end())
|
||||
{
|
||||
m_devGDevInfoMap[devg].insert(tag,desc);
|
||||
}else
|
||||
{
|
||||
QMap<QString,QString> devMap;
|
||||
devMap.insert(tag,desc);
|
||||
m_devGDevInfoMap[devg] = devMap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CDbInterface::readUnitInfo()
|
||||
{
|
||||
if(!m_pReadDb->isOpen())
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_mapUnit.clear();
|
||||
QSqlQuery query;
|
||||
QString sqlQuery = QString("select UNIT_ID,UNIT_NAME from dict_unit_info");
|
||||
|
||||
m_pReadDb->execute(sqlQuery, query);
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
int id = query.value(0).toInt();
|
||||
QString name = query.value(1).toString();
|
||||
|
||||
m_mapUnit.insert(id, name);
|
||||
}
|
||||
}
|
||||
|
||||
void CDbInterface::readDiStatus()
|
||||
{
|
||||
if(!m_pReadDb->isOpen())
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_mapDiStatus.clear();
|
||||
QSqlQuery query;
|
||||
QString sqlQuery = QString("select ACTUAL_VALUE,DISPLAY_VALUE from dict_menu_info where MENU_NAME='%1'").arg(DI_STATUS_MENU_NAME);
|
||||
|
||||
m_pReadDb->execute(sqlQuery, query);
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
int id = query.value(0).toInt();
|
||||
QString name = query.value(1).toString();
|
||||
|
||||
m_mapDiStatus.insert(id, name);
|
||||
}
|
||||
}
|
||||
|
||||
void CDbInterface::readAiStatus()
|
||||
{
|
||||
if(!m_pReadDb->isOpen())
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_mapAiStatus.clear();
|
||||
QSqlQuery query;
|
||||
QString sqlQuery = QString("select ACTUAL_VALUE,DISPLAY_VALUE from dict_menu_info where MENU_NAME='%1'").arg(AI_STATUS_MENU_NAME);
|
||||
|
||||
m_pReadDb->execute(sqlQuery, query);
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
int id = query.value(0).toInt();
|
||||
QString name = query.value(1).toString();
|
||||
|
||||
m_mapAiStatus.insert(id, name);
|
||||
}
|
||||
}
|
||||
|
||||
QVariantList CDbInterface::rdbNetGetByKey(const int &appId, const QString &tableName, const QString &keyInfo, const QString &columnsName, const int &domainId, bool asyn)
|
||||
{
|
||||
QVariantList result;
|
||||
iot_idl::RdbQuery objQuery;
|
||||
iot_idl::RdbRet objReply;
|
||||
m_rdbNetAccess->connect(domainId, appId);
|
||||
|
||||
objQuery.set_strtablename(tableName.toStdString());
|
||||
QStringList tmpList = columnsName.split(",");
|
||||
for(int i = 0; i < tmpList.count(); i++)
|
||||
{
|
||||
std::string *pColName = objQuery.add_strselectcolnamearr();
|
||||
*pColName = tmpList[i].toStdString();
|
||||
}
|
||||
|
||||
iot_idl::RdbCondition *pCondtion = objQuery.add_msgcondition();
|
||||
pCondtion->set_enrelation(ENConditionRelation::enumCondEqual);
|
||||
pCondtion->set_strcolumnname("tag_name");
|
||||
SVariable *pCondValue = pCondtion->mutable_msgvalue();
|
||||
pCondValue->set_edatatype(DataType::CN_DATATYPE_STRING);
|
||||
pCondValue->set_strvalue(keyInfo.toStdString());
|
||||
|
||||
bool ret = m_rdbNetAccess->query(objQuery, objReply, asyn);
|
||||
if(!ret)
|
||||
{
|
||||
result.push_back(-1);
|
||||
//LOGINFO("CRdbNetApi query %s %s %s failed", appName.toStdString().c_str(), tableName.toStdString().c_str(), keyInfo.toStdString().c_str());
|
||||
}
|
||||
else if(!asyn)
|
||||
{
|
||||
QVariantList columnValueList;
|
||||
int recordNum = objReply.msgrecord_size();
|
||||
int columnNum = 0;
|
||||
result.push_back(recordNum);
|
||||
|
||||
for (int i = 0; i < recordNum; ++i)
|
||||
{
|
||||
columnValueList.clear();
|
||||
columnNum = objReply.msgrecord(i).msgvaluearray_size();
|
||||
for (int j = 0; j < columnNum; ++j)
|
||||
{
|
||||
switch (objReply.msgrecord(i).msgvaluearray(j).edatatype())
|
||||
{
|
||||
case DataType::CN_DATATYPE_BOOL:
|
||||
columnValueList << QVariant::fromValue(objReply.msgrecord(i).msgvaluearray(j).bvalue());
|
||||
break;
|
||||
case CN_DATATYPE_FLOAT:
|
||||
columnValueList << QVariant::fromValue(objReply.msgrecord(i).msgvaluearray(j).fvalue());
|
||||
break;
|
||||
case CN_DATATYPE_INT32:
|
||||
columnValueList << QVariant::fromValue(objReply.msgrecord(i).msgvaluearray(j).nvalue());
|
||||
break;
|
||||
case CN_DATATYPE_UINT32:
|
||||
columnValueList << QVariant::fromValue(objReply.msgrecord(i).msgvaluearray(j).uvalue());
|
||||
break;
|
||||
case CN_DATATYPE_INT64:
|
||||
columnValueList << QVariant::fromValue(objReply.msgrecord(i).msgvaluearray(j).lvalue());
|
||||
break;
|
||||
case CN_DATATYPE_UINT64:
|
||||
columnValueList << QVariant::fromValue(objReply.msgrecord(i).msgvaluearray(j).ulvalue());
|
||||
break;
|
||||
case CN_DATATYPE_DOUBLE:
|
||||
columnValueList << QVariant::fromValue(objReply.msgrecord(i).msgvaluearray(j).dvalue());
|
||||
break;
|
||||
case CN_DATATYPE_STRING:
|
||||
{
|
||||
std::string strValue = objReply.msgrecord(i).msgvaluearray(j).strvalue();
|
||||
columnValueList << QString::fromStdString(strValue);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
result << columnValueList;
|
||||
}
|
||||
}
|
||||
else
|
||||
{}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user