3074 lines
105 KiB
C++
3074 lines
105 KiB
C++
#include "CAlarmForm.h"
|
||
#include <QMenu>
|
||
#include <QMessageBox>
|
||
#include <QFileDialog>
|
||
#include <QSettings>
|
||
#include <QLineEdit>
|
||
#include <QPushButton>
|
||
#include <QTreeWidget>
|
||
#include <QContextMenuEvent>
|
||
#include <QSortFilterProxyModel>
|
||
#include "ui_CAlarmForm.h"
|
||
#include "CAlarmDelegate.h"
|
||
#include "CAiAlarmDelegate.h"
|
||
#include "CAlarmItemModel.h"
|
||
#include "CAlarmFilterDialog.h"
|
||
#include "CAlarmMsgManage.h"
|
||
#include "CTableViewPrinter.h"
|
||
#include "CAlarmDataCollect.h"
|
||
#include "CAiAlarmDataCollect.h"
|
||
#include "CAlarmInhibitDialog.h"
|
||
#include "CAlarmDeviceTreeModel.h"
|
||
#include "CAlarmDeviceTreeItem.h"
|
||
#include "CAiAlarmTreeItem.h"
|
||
#include "CAiAlarmTreeModel.h"
|
||
#include "perm_mng_api/PermMngApi.h"
|
||
#include <QDebug>
|
||
#include <QCheckBox>
|
||
#include "CMyListWidget.h"
|
||
#include "CMyCheckBox.h"
|
||
#include "CDisposalPlanDialog.h"
|
||
#include "CTreeViewPrinter.h"
|
||
#include "pub_logger_api/logger.h"
|
||
#include "pub_utility_api/FileUtil.h"
|
||
#include <QDomDocument>
|
||
#include "CAlarmTaskMngDlg.h"
|
||
#include <QToolTip>
|
||
#include "CAlarmSetDlg.h"
|
||
#include "CAlarmBaseData.h"
|
||
#include "CAlarmShiledDialog.h"
|
||
#include "CAccidentReviewDialog.h"
|
||
#include "pub_utility_api/FileStyle.h"
|
||
CAlarmForm::CAlarmForm(QWidget *parent) :
|
||
QWidget(parent),
|
||
m_ptrSysInfo(Q_NULLPTR),
|
||
m_pReadDb(Q_NULLPTR),
|
||
m_aiOptPerm(true),
|
||
m_pModel(Q_NULLPTR),
|
||
m_delegate(Q_NULLPTR),
|
||
m_aiDelegate(Q_NULLPTR),
|
||
m_treeModel(Q_NULLPTR),
|
||
m_communicator(Q_NULLPTR),
|
||
ui(new Ui::CAlarmForm),
|
||
m_isNormal(true),
|
||
m_isNeedAccidentReview(true),
|
||
m_strAccidenPath(QString())
|
||
{
|
||
m_communicator = new iot_net::CMbCommunicator();
|
||
qRegisterMetaType<QItemSelection>("QItemSelection");
|
||
qRegisterMetaType< QList<QVector<QString> > >("QList<QVector<QString> >");
|
||
qRegisterMetaType<QVector<bool> >("QVector<bool>");
|
||
qRegisterMetaType<QVector<double> >("QVector<double>");
|
||
qRegisterMetaType<QVector<QString> >("QVector<QString>");
|
||
ui->setupUi(this);
|
||
ui->alarmView->setObjectName("alarmView");
|
||
ui->splitter->setStretchFactor(0,1);
|
||
ui->splitter->setStretchFactor(1,6);
|
||
initStyle();
|
||
QHBoxLayout * pHBoxLayout = new QHBoxLayout(ui->deviceView->header());
|
||
m_pSearchTextEdit = new QLineEdit(ui->deviceView->header());
|
||
m_pSearchTextEdit->setObjectName("searchTextEdit");
|
||
m_pSearchTextEdit->setTextMargins(0, 0, 21, 0);
|
||
m_pSearchTextEdit->setPlaceholderText(tr("按设备组关键字搜索"));
|
||
pHBoxLayout->addWidget(m_pSearchTextEdit);
|
||
pHBoxLayout->setContentsMargins(2,0,2,0);
|
||
pHBoxLayout->setSpacing(0);
|
||
ui->deviceView->header()->setLayout(pHBoxLayout);
|
||
ui->deviceView->header()->setObjectName("deviceHeader");
|
||
//ui->deviceView->header()->setFixedHeight(30);
|
||
|
||
m_pSearchButton = new QPushButton(this);
|
||
m_pSearchButton->setObjectName("searchButton");
|
||
m_pSearchButton->setText("");
|
||
m_pSearchButton->setMaximumSize(21, 22);
|
||
m_pSearchButton->setCursor(QCursor(Qt::ArrowCursor));
|
||
|
||
QHBoxLayout * pSearchLayout = new QHBoxLayout();
|
||
pSearchLayout->setContentsMargins(1, 1, 1, 1);
|
||
pSearchLayout->addStretch();
|
||
pSearchLayout->addWidget(m_pSearchButton);
|
||
m_pSearchTextEdit->setLayout(pSearchLayout);
|
||
|
||
connect(m_pSearchTextEdit, &QLineEdit::returnPressed, this, &CAlarmForm::searchDeviceName);
|
||
connect(m_pSearchButton, &QPushButton::clicked, this, &CAlarmForm::searchDeviceName);
|
||
m_pListWidget1 = new CMyListWidget(this);
|
||
m_pListWidget2 = new CMyListWidget(this);
|
||
m_pListWidget3 = new CMyListWidget(this);
|
||
m_pLineEdit1 = new QLineEdit(this);
|
||
m_pLineEdit2 = new QLineEdit(this);
|
||
m_pLineEdit3 = new QLineEdit(this);
|
||
m_timeIcon = new QPushButton(this);
|
||
//时间过滤
|
||
m_myCalendar = new CMyCalendar(this);
|
||
QWidgetAction *widgetAction=new QWidgetAction(this);
|
||
m_timeMenu = new QMenu(this);
|
||
widgetAction->setDefaultWidget(m_myCalendar);
|
||
m_timeMenu->addAction(widgetAction);
|
||
m_timeIcon->setObjectName("iconButton");
|
||
m_timeIcon->setText("");
|
||
m_timeIcon->setMaximumSize(21, 22);
|
||
m_timeIcon->setCursor(QCursor(Qt::ArrowCursor));
|
||
QHBoxLayout * pTimeLayout = new QHBoxLayout();
|
||
pTimeLayout->setContentsMargins(1, 1, 1, 1);
|
||
pTimeLayout->addStretch();
|
||
pTimeLayout->addWidget(m_timeIcon);
|
||
ui->lineEdit->setLayout(pTimeLayout);
|
||
connect(m_timeIcon,&QPushButton::clicked,this,&CAlarmForm::myCalendarShow);
|
||
connect(m_myCalendar,&CMyCalendar::sig_endTimeClick,this,&CAlarmForm::myCalendarHide);
|
||
connect(m_myCalendar,&CMyCalendar::sig_cancle,this,&CAlarmForm::cancleTimeFilter);
|
||
ui->lineEdit->setText(tr("请选择时间"));
|
||
ui->lineEdit->setReadOnly(true);
|
||
ui->lineEdit->setObjectName("iconLineEdit");
|
||
|
||
m_pdfPrinter = new CPdfPrinter();
|
||
m_thread = new QThread();
|
||
m_pdfPrinter->moveToThread(m_thread);
|
||
connect(m_thread,&QThread::started,m_pdfPrinter,&CPdfPrinter::initialize);
|
||
connect(m_thread,&QThread::finished,m_pdfPrinter,&CPdfPrinter::deleteLater);
|
||
connect(this,&CAlarmForm::printExcel,m_pdfPrinter,&CPdfPrinter::printerByModel);
|
||
connect(this,&CAlarmForm::printExcelAlm,m_pdfPrinter,&CPdfPrinter::printerAlmByModel);
|
||
connect(m_pdfPrinter,&CPdfPrinter::printResult,this,&CAlarmForm::printMess);
|
||
ui->aiAlarmTreeView->setUpdatesEnabled(false);
|
||
ui->alarmView->setUpdatesEnabled(false);
|
||
m_thread->start();
|
||
}
|
||
|
||
void CAlarmForm::initStyle(){
|
||
QString qss = QString();
|
||
std::string strFullPath = iot_public::CFileStyle::getPathOfStyleFile("alarmForm.qss") ;
|
||
QFile qssfile2(QString::fromStdString(strFullPath));
|
||
qssfile2.open(QFile::ReadOnly);
|
||
if (qssfile2.isOpen())
|
||
{
|
||
qss += QLatin1String(qssfile2.readAll());
|
||
qssfile2.close();
|
||
}
|
||
if(!qss.isEmpty())
|
||
{
|
||
setStyleSheet(qss);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
CAlarmForm::~CAlarmForm()
|
||
{
|
||
if(m_communicator != Q_NULLPTR)
|
||
{
|
||
delete m_communicator;
|
||
}
|
||
m_communicator =Q_NULLPTR;
|
||
|
||
if(m_pReadDb)
|
||
{
|
||
m_pReadDb->close();
|
||
delete m_pReadDb;
|
||
}
|
||
m_pReadDb = NULL;
|
||
if(m_delegate)
|
||
{
|
||
delete m_delegate;
|
||
}
|
||
m_delegate = Q_NULLPTR;
|
||
|
||
if(m_aiDelegate)
|
||
{
|
||
delete m_aiDelegate;
|
||
}
|
||
m_aiDelegate = Q_NULLPTR;
|
||
|
||
if(m_pdfPrinter)
|
||
{
|
||
delete m_pdfPrinter;
|
||
}
|
||
m_pdfPrinter = Q_NULLPTR;
|
||
|
||
if(m_thread)
|
||
{
|
||
m_thread->quit();
|
||
m_thread->wait();
|
||
}
|
||
|
||
delete ui;
|
||
LOGDEBUG("CAlarmForm::~CAlarmForm()");
|
||
}
|
||
|
||
void CAlarmForm::initialize()
|
||
{
|
||
if (!iot_public::createSysInfoInstance(m_ptrSysInfo))
|
||
{
|
||
LOGERROR("创建系统信息访问库实例失败!");
|
||
}
|
||
if(m_pReadDb == NULL)
|
||
{
|
||
m_pReadDb = new iot_dbms::CDbApi(DB_CONN_MODEL_READ);
|
||
if(!m_pReadDb->open())
|
||
{
|
||
LOGERROR("数据库打开失败,%s",m_pReadDb->getLastErrorString().toStdString().c_str());
|
||
}
|
||
}
|
||
m_pDeviceModel = new CAlarmDeviceTreeModel(this);
|
||
ui->deviceView->setModel(m_pDeviceModel);
|
||
connect(ui->set,&QPushButton::clicked,this,&CAlarmForm::slot_showColorSet);
|
||
connect(ui->checkBox,SIGNAL(stateChanged(int)),this,SLOT(slot_changePage(int)));
|
||
connect(ui->filter, SIGNAL(clicked()), this, SLOT(updateFilter()));
|
||
connect(ui->remove, SIGNAL(clicked()), this, SLOT(slot_removeAlarm()));
|
||
connect(ui->confirm, SIGNAL(clicked()), this, SLOT(slot_confirmAlarm()));
|
||
|
||
//connect(ui->inhibit, SIGNAL(clicked()), this, SLOT(slot_showInhibitAlarm()));
|
||
connect(ui->inhibit, SIGNAL(clicked()), this, SLOT(slot_showShiledAlarm()));
|
||
|
||
connect(ui->print, SIGNAL(clicked()), this, SLOT(print()));
|
||
connect(ui->closeBtn, &QPushButton::clicked, this, &CAlarmForm::closeBtnClicked);
|
||
connect(ui->inhiAlarm, &QPushButton::clicked, this, &CAlarmForm::slotInhibitAlarm);
|
||
setHiddenInhiAlarmButton(true);
|
||
updateAlarmOperatePerm();
|
||
|
||
//< lingdaoyaoqiu
|
||
{
|
||
QSettings columFlags("IOT_HMI", "alarm config");
|
||
if(!columFlags.contains(QString("alarm/colum_0")))
|
||
{
|
||
columFlags.setValue(QString("alarm/colum_0"), false); //< 时间
|
||
columFlags.setValue(QString("alarm/colum_1"), false); //< 优先级
|
||
columFlags.setValue(QString("alarm/colum_2"), false); //< 位置
|
||
columFlags.setValue(QString("alarm/colum_3"), true); //< 责任区
|
||
columFlags.setValue(QString("alarm/colum_4"), true); //< 告警类型
|
||
columFlags.setValue(QString("alarm/colum_5"), false); //< 告警状态
|
||
columFlags.setValue(QString("alarm/colum_6"), true); //< 确认状态
|
||
columFlags.setValue(QString("alarm/colum_7"), true); //<
|
||
}
|
||
}
|
||
ui->comboBox->setModel(m_pListWidget1->model());
|
||
ui->comboBox->setView(m_pListWidget1);
|
||
ui->comboBox->setLineEdit(m_pLineEdit1);
|
||
m_strText1 = tr("请选择优先级");
|
||
m_pLineEdit1->setText(tr("请选择优先级"));
|
||
m_pLineEdit1->setReadOnly(true);
|
||
connect(m_pLineEdit1, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged1(const QString &))); //为了解决点击下拉框白色部分导致lineedit无数据问题
|
||
ui->comboBox_2->setModel(m_pListWidget2->model());
|
||
ui->comboBox_2->setView(m_pListWidget2);
|
||
ui->comboBox_2->setLineEdit(m_pLineEdit2);
|
||
m_strText2 = tr("请选择位置");
|
||
m_pLineEdit2->setText(tr("请选择位置"));
|
||
m_pLineEdit2->setReadOnly(true);
|
||
connect(m_pLineEdit2, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged2(const QString &)));
|
||
ui->comboBox_3->setModel(m_pListWidget3->model());
|
||
ui->comboBox_3->setView(m_pListWidget3);
|
||
ui->comboBox_3->setLineEdit(m_pLineEdit3);
|
||
m_strText3 = tr("请选择告警状态");
|
||
m_pLineEdit3->setText(tr("请选择告警状态"));
|
||
m_pLineEdit3->setReadOnly(true);
|
||
connect(m_pLineEdit3, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged3(const QString &)));
|
||
}
|
||
|
||
void CAlarmForm::init()
|
||
{
|
||
reloadDevTree();
|
||
initFilter();
|
||
}
|
||
|
||
void CAlarmForm::updateAlarmOperatePerm()
|
||
{
|
||
m_listRegionOptId.clear();
|
||
m_listLocationOptId.clear();
|
||
m_listRegionDelId.clear();
|
||
m_listLocationDelId.clear();
|
||
iot_public::SNodeInfo stNodeInfo;
|
||
if (!m_ptrSysInfo)
|
||
{
|
||
if(!createSysInfoInstance(m_ptrSysInfo))
|
||
{
|
||
LOGERROR("创建系统信息访问库实例失败!");
|
||
return;
|
||
}
|
||
}
|
||
m_ptrSysInfo->getLocalNodeInfo(stNodeInfo);
|
||
m_nodeName = stNodeInfo.strName;
|
||
m_nDomainId = stNodeInfo.nDomainId;
|
||
|
||
iot_service::CPermMngApiPtr permMngPtr = iot_service::getPermMngInstance("base");
|
||
if(permMngPtr != NULL)
|
||
{
|
||
permMngPtr->PermDllInit();
|
||
int nUserGrpId;
|
||
int nLevel;
|
||
int nLoginSec;
|
||
std::string strInstanceName;
|
||
if(PERM_NORMAL != permMngPtr->CurUser(m_userId, nUserGrpId, nLevel, nLoginSec, strInstanceName))
|
||
{
|
||
m_userId = -1;
|
||
LOGERROR("用户ID获取失败!");
|
||
return;
|
||
}
|
||
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++);
|
||
}
|
||
}
|
||
|
||
std::string str = "FUNC_NOM_IA_EDIT";
|
||
if(PERM_PERMIT != permMngPtr->PermCheck(PERM_NOM_FUNC_DEF,&str))
|
||
{
|
||
m_aiOptPerm = false;
|
||
LOGINFO("无智能告警编辑权限");
|
||
}else
|
||
{
|
||
m_aiOptPerm = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::setAlarmOperateEnable(const bool &bEnable)
|
||
{
|
||
ui->confirm->setEnabled(bEnable);
|
||
ui->remove->setEnabled(bEnable);
|
||
m_isNormal = bEnable;
|
||
}
|
||
|
||
void CAlarmForm::setColumnWidth(const int &column, const int &width)
|
||
{
|
||
if(ui->alarmView != Q_NULLPTR)
|
||
{
|
||
ui->alarmView->setColumnWidth(column, width);
|
||
}
|
||
if(ui->aiAlarmTreeView != Q_NULLPTR)
|
||
{
|
||
ui->aiAlarmTreeView->setColumnWidth(column, width);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::setColumnVisible(const int &column, const bool &visible)
|
||
{
|
||
if(ui->alarmView != Q_NULLPTR)
|
||
{
|
||
ui->alarmView->setColumnHidden(column, !visible);
|
||
}
|
||
if(ui->aiAlarmTreeView != Q_NULLPTR)
|
||
{
|
||
ui->aiAlarmTreeView->setColumnHidden(column, !visible);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::setEnableAccidentReview(bool isNeed)
|
||
{
|
||
m_isNeedAccidentReview = isNeed;
|
||
}
|
||
|
||
void CAlarmForm::setEnableTrend(bool isNeed)
|
||
{
|
||
if(m_delegate)
|
||
{
|
||
m_delegate->setEnableTrend(isNeed);
|
||
}
|
||
if(m_aiDelegate)
|
||
{
|
||
m_aiDelegate->setEnableTrend(isNeed);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::setEnableVideo(bool isNeed)
|
||
{
|
||
if(m_delegate)
|
||
{
|
||
m_delegate->setEnableVideo(isNeed);
|
||
}
|
||
if(m_aiDelegate)
|
||
{
|
||
m_aiDelegate->setEnableVideo(isNeed);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::setEnableWave(bool isNeed)
|
||
{
|
||
if(m_delegate)
|
||
{
|
||
m_delegate->setEnableWave(isNeed);
|
||
}
|
||
if(m_aiDelegate)
|
||
{
|
||
m_aiDelegate->setEnableWave(isNeed);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::setEnableLevel(bool isNeed)
|
||
{
|
||
if(m_delegate)
|
||
{
|
||
m_delegate->setEnableLevel(isNeed);
|
||
}
|
||
if(m_aiDelegate)
|
||
{
|
||
m_aiDelegate->setEnableLevel(isNeed);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::setHiddenLocation(bool hide)
|
||
{
|
||
ui->label_4->setHidden(hide);
|
||
ui->comboBox_2->setHidden(hide);
|
||
}
|
||
|
||
void CAlarmForm::setHiddenTime(bool hide)
|
||
{
|
||
ui->label_6->setHidden(hide);
|
||
ui->lineEdit->setHidden(hide);
|
||
}
|
||
|
||
void CAlarmForm::setHiddenStatus(bool hide)
|
||
{
|
||
ui->label_5->setHidden(hide);
|
||
ui->comboBox_3->setHidden(hide);
|
||
}
|
||
|
||
void CAlarmForm::setHiddenPriority(bool hide)
|
||
{
|
||
ui->label_3->setHidden(hide);
|
||
ui->comboBox->setHidden(hide);
|
||
}
|
||
|
||
void CAlarmForm::setHiddenCheckBox(bool hide)
|
||
{
|
||
ui->checkBox->setHidden(hide);
|
||
}
|
||
|
||
void CAlarmForm::setHiddenSetConfig(bool hide)
|
||
{
|
||
ui->set->setHidden(hide);
|
||
}
|
||
|
||
void CAlarmForm::setHiddenCloseButton(bool hide)
|
||
{
|
||
ui->closeBtn->setHidden(hide);
|
||
}
|
||
|
||
void CAlarmForm::setHiddenInhiAlarmButton(bool hide)
|
||
{
|
||
ui->inhiAlarm->setHidden(hide);
|
||
}
|
||
|
||
void CAlarmForm::setShowAiAlarmView(bool show)
|
||
{
|
||
if(m_treeModel)
|
||
{
|
||
ui->checkBox->setHidden(false);
|
||
ui->checkBox->setChecked(show);
|
||
}else
|
||
{
|
||
ui->checkBox->setHidden(true);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::setRowHeight(int height)
|
||
{
|
||
if(ui->alarmView != Q_NULLPTR)
|
||
{
|
||
ui->alarmView->setDefaultRowHeight(height);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::setAccidentReviewPath(const QString &path)
|
||
{
|
||
m_strAccidenPath = path;
|
||
}
|
||
|
||
void CAlarmForm::initFilter()
|
||
{
|
||
m_pListWidget1->clear();
|
||
m_pListWidget2->clear();
|
||
m_pListWidget3->clear();
|
||
QMap<int, QString> priority = CAlarmBaseData::instance()->getPermPriorityMap();
|
||
QMap<int, QString> alarmStatus = CAlarmBaseData::instance()->getAlarmShowStatusMap();
|
||
for(QMap<int, QString>::iterator it1 = priority.begin();it1 != priority.end();++it1)
|
||
{
|
||
QListWidgetItem *pItem = new QListWidgetItem(m_pListWidget1);
|
||
pItem->setData(Qt::UserRole, it1.key());
|
||
CMyCheckBox *pCheckBox = new CMyCheckBox(this);
|
||
pCheckBox->setText(it1.value());
|
||
m_pListWidget1->addItem(pItem);
|
||
m_pListWidget1->setItemWidget(pItem, pCheckBox);
|
||
connect(pCheckBox, SIGNAL(stateChanged(int)), this, SLOT(stateChanged1(int)));
|
||
}
|
||
|
||
QList<int> locationList = CAlarmBaseData::instance()->getPermLocationOrder();
|
||
foreach (const int locId, locationList) {
|
||
QString locDesc = CAlarmBaseData::instance()->getPermLocationDesc(locId);
|
||
QListWidgetItem *pItem = new QListWidgetItem(m_pListWidget2);
|
||
pItem->setData(Qt::UserRole, locId);
|
||
CMyCheckBox *pCheckBox = new CMyCheckBox(this);
|
||
pCheckBox->setText(locDesc);
|
||
m_pListWidget2->addItem(pItem);
|
||
m_pListWidget2->setItemWidget(pItem, pCheckBox);
|
||
connect(pCheckBox, SIGNAL(stateChanged(int)), this, SLOT(stateChanged2(int)));
|
||
}
|
||
|
||
for(QMap<int, QString>::iterator it3 = alarmStatus.begin();it3 != alarmStatus.end();++it3)
|
||
{
|
||
QListWidgetItem *pItem = new QListWidgetItem(m_pListWidget3);
|
||
pItem->setData(Qt::UserRole, it3.key());
|
||
CMyCheckBox *pCheckBox = new CMyCheckBox(this);
|
||
pCheckBox->setText(it3.value());
|
||
m_pListWidget3->addItem(pItem);
|
||
m_pListWidget3->setItemWidget(pItem, pCheckBox);
|
||
connect(pCheckBox, SIGNAL(stateChanged(int)), this, SLOT(stateChanged3(int)));
|
||
}
|
||
m_strText1 = tr("请选择优先级");
|
||
m_strText2 = tr("请选择位置");
|
||
m_strText3 = tr("请选择告警状态");
|
||
m_pLineEdit1->setText(m_strText1);
|
||
m_pLineEdit2->setText(m_strText2);
|
||
m_pLineEdit3->setText(m_strText3);
|
||
}
|
||
|
||
void CAlarmForm::setLevelComboBox(bool &isLevelFilter, QList<int> &listLevel)
|
||
{
|
||
if(isLevelFilter == true && listLevel.size() > 0)
|
||
{
|
||
QString strText("");
|
||
for (int i = 0; i < m_pListWidget1->count(); ++i)
|
||
{
|
||
QListWidgetItem *pItem = m_pListWidget1->item(i);
|
||
QWidget *pWidget = m_pListWidget1->itemWidget(pItem);
|
||
CMyCheckBox *pCheckBox = (CMyCheckBox *)pWidget;
|
||
int nData = pItem->data(Qt::UserRole).toInt();
|
||
if(listLevel.contains(nData))
|
||
{
|
||
pCheckBox->blockSignals(true);
|
||
pCheckBox->setChecked(true);
|
||
strText.append(pCheckBox->text()).append(" ");
|
||
pCheckBox->blockSignals(false);
|
||
}else
|
||
{
|
||
pCheckBox->blockSignals(true);
|
||
pCheckBox->setChecked(false);
|
||
pCheckBox->blockSignals(false);
|
||
}
|
||
}
|
||
m_strText1 = strText;
|
||
m_pLineEdit1->setText(strText);
|
||
}else
|
||
{
|
||
for (int i = 0; i < m_pListWidget1->count(); ++i)
|
||
{
|
||
QListWidgetItem *pItem = m_pListWidget1->item(i);
|
||
QWidget *pWidget = m_pListWidget1->itemWidget(pItem);
|
||
CMyCheckBox *pCheckBox = (CMyCheckBox *)pWidget;
|
||
pCheckBox->blockSignals(true);
|
||
pCheckBox->setChecked(false);
|
||
pCheckBox->blockSignals(false);
|
||
}
|
||
m_strText1 = tr("请选择优先级");
|
||
m_pLineEdit1->setText(tr("请选择优先级"));
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::setLocationComboBox(bool &isLocationFilter,QList<int> &listLocation)
|
||
{
|
||
if(isLocationFilter == true && listLocation.size() > 0)
|
||
{
|
||
QString strText("");
|
||
for (int i = 0; i < m_pListWidget2->count(); ++i)
|
||
{
|
||
QListWidgetItem *pItem = m_pListWidget2->item(i);
|
||
QWidget *pWidget = m_pListWidget2->itemWidget(pItem);
|
||
CMyCheckBox *pCheckBox = (CMyCheckBox *)pWidget;
|
||
int nData = pItem->data(Qt::UserRole).toInt();
|
||
if(listLocation.contains(nData))
|
||
{
|
||
pCheckBox->blockSignals(true);
|
||
pCheckBox->setChecked(true);
|
||
strText.append(pCheckBox->text()).append(" ");
|
||
pCheckBox->blockSignals(false);
|
||
}else
|
||
{
|
||
pCheckBox->blockSignals(true);
|
||
pCheckBox->setChecked(false);
|
||
pCheckBox->blockSignals(false);
|
||
}
|
||
}
|
||
m_strText2 = strText;
|
||
m_pLineEdit2->setText(strText);
|
||
}else
|
||
{
|
||
for (int i = 0; i < m_pListWidget2->count(); ++i)
|
||
{
|
||
QListWidgetItem *pItem = m_pListWidget2->item(i);
|
||
QWidget *pWidget = m_pListWidget2->itemWidget(pItem);
|
||
CMyCheckBox *pCheckBox = (CMyCheckBox *)pWidget;
|
||
pCheckBox->blockSignals(true);
|
||
pCheckBox->setChecked(false);
|
||
pCheckBox->blockSignals(false);
|
||
}
|
||
m_strText2 = tr("请选择位置");
|
||
m_pLineEdit2->setText(tr("请选择位置"));
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::setAlarmStatusComboBox(bool &isAlarmTypeFilter, QList<int> &listAlarmStatus)
|
||
{
|
||
if(isAlarmTypeFilter == true && listAlarmStatus.size() > 0)
|
||
{
|
||
QString strText("");
|
||
for (int i = 0; i < m_pListWidget3->count(); ++i)
|
||
{
|
||
QListWidgetItem *pItem = m_pListWidget3->item(i);
|
||
QWidget *pWidget = m_pListWidget3->itemWidget(pItem);
|
||
CMyCheckBox *pCheckBox = (CMyCheckBox *)pWidget;
|
||
int nData = pItem->data(Qt::UserRole).toInt();
|
||
if(listAlarmStatus.contains(nData))
|
||
{
|
||
pCheckBox->blockSignals(true);
|
||
pCheckBox->setChecked(true);
|
||
strText.append(pCheckBox->text()).append(" ");
|
||
pCheckBox->blockSignals(false);
|
||
}else
|
||
{
|
||
pCheckBox->blockSignals(true);
|
||
pCheckBox->setChecked(false);
|
||
pCheckBox->blockSignals(false);
|
||
}
|
||
}
|
||
m_strText3 = strText;
|
||
m_pLineEdit3->setText(strText);
|
||
}else
|
||
{
|
||
for (int i = 0; i < m_pListWidget3->count(); ++i)
|
||
{
|
||
QListWidgetItem *pItem = m_pListWidget3->item(i);
|
||
QWidget *pWidget = m_pListWidget3->itemWidget(pItem);
|
||
CMyCheckBox *pCheckBox = (CMyCheckBox *)pWidget;
|
||
pCheckBox->blockSignals(true);
|
||
pCheckBox->setChecked(false);
|
||
pCheckBox->blockSignals(false);
|
||
}
|
||
m_strText3 = tr("请选择告警状态");
|
||
m_pLineEdit3->setText(tr("请选择告警状态"));
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::setAlarmTimeLineEdit(bool &isTimeFilter, QDateTime &startTime, QDateTime &endTime)
|
||
{
|
||
if(isTimeFilter == true)
|
||
{
|
||
ui->lineEdit->setText(startTime.date().toString("yyyy-MM-dd")+"~"+endTime.date().toString("yyyy-MM-dd"));
|
||
}else
|
||
{
|
||
ui->lineEdit->setText(tr("请选择时间"));
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::setAlarmModel(CAlarmItemModel *model,CAiAlarmTreeModel *treeModel)
|
||
{
|
||
ui->checkBox->setChecked(true);
|
||
slot_changePage(0);
|
||
ui->alarmView->horizontalHeader()->setSortIndicator(0, Qt::AscendingOrder);
|
||
ui->aiAlarmTreeView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||
m_pModel = model;
|
||
m_delegate = new CAlarmDelegate(m_pModel, ui->alarmView);
|
||
connect(m_delegate,&CAlarmDelegate::openVideo,this,&CAlarmForm::openVideo,Qt::QueuedConnection);
|
||
connect(m_delegate,&CAlarmDelegate::openTrend,this,&CAlarmForm::openTrend,Qt::QueuedConnection);
|
||
connect(CAlarmSetMng::instance(),&CAlarmSetMng::sigLoadConfig,m_delegate,&CAlarmDelegate::slotLoadConfig,Qt::QueuedConnection);
|
||
ui->alarmView->initialize();
|
||
ui->aiAlarmTreeView->initialize();
|
||
ui->alarmView->setItemDelegate(m_delegate);
|
||
ui->alarmView->setModel(m_pModel);
|
||
m_treeModel = treeModel;
|
||
m_aiDelegate = new CAiAlarmDelegate(m_treeModel,ui->aiAlarmTreeView);
|
||
ui->aiAlarmTreeView->setItemDelegate(m_aiDelegate);
|
||
ui->aiAlarmTreeView->setModel(m_treeModel);
|
||
connect(m_aiDelegate,&CAiAlarmDelegate::openVideo,this,&CAlarmForm::openVideo,Qt::QueuedConnection);
|
||
connect(m_aiDelegate,&CAiAlarmDelegate::openTrend,this,&CAlarmForm::openTrend,Qt::QueuedConnection);
|
||
connect(CAlarmSetMng::instance(),&CAlarmSetMng::sigLoadConfig,m_aiDelegate,&CAiAlarmDelegate::slotLoadConfig,Qt::QueuedConnection);
|
||
//< 性能损耗
|
||
//connect(ui->alarmView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(slot_selectionChanged()), Qt::QueuedConnection);
|
||
|
||
connect(ui->alarmView->horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), m_pModel, SLOT(sortColumn(int,Qt::SortOrder)));
|
||
connect(ui->aiAlarmTreeView->header(),&QHeaderView::sortIndicatorChanged, m_treeModel,&CAiAlarmTreeModel::sortColumn);
|
||
//先注释掉,想启用的话可以通过脚本绑定
|
||
//connect(ui->aiAlarmTreeView,&CAiAlarmTreeView::doubleClicked, this,&CAlarmForm::aiAlmDoubleClicked);
|
||
ui->confirm->setEnabled(true);
|
||
ui->remove->setEnabled(true);
|
||
//原始告警窗
|
||
|
||
ui->alarmView->setColumnWidth(0, 230);
|
||
ui->alarmView->setColumnWidth(1, 120);
|
||
ui->alarmView->setColumnWidth(2, 150);
|
||
ui->alarmView->setColumnWidth(5, 150);
|
||
ui->alarmView->setColumnWidth(6, 120);
|
||
|
||
QSettings columFlags("IOT_HMI", "alarm config");
|
||
for(int nColumnIndex(0); nColumnIndex < m_pModel->columnCount() - 1; nColumnIndex++)
|
||
{
|
||
bool visible = columFlags.value(QString("alarm/colum_%1").arg(nColumnIndex)).toBool();
|
||
ui->alarmView->setColumnHidden(nColumnIndex, visible);
|
||
}
|
||
ui->alarmView->setColumnHidden(m_pModel->columnCount() - 1, false);
|
||
//智能告警窗
|
||
ui->aiAlarmTreeView->setColumnWidth(0, 230);
|
||
ui->aiAlarmTreeView->setColumnWidth(1, 120);
|
||
ui->aiAlarmTreeView->setColumnWidth(2, 150);
|
||
ui->aiAlarmTreeView->setColumnWidth(5, 150);
|
||
ui->aiAlarmTreeView->setColumnWidth(6, 120);
|
||
|
||
for(int nColumnIndex(0); nColumnIndex < m_treeModel->columnCount(); nColumnIndex++)
|
||
{
|
||
bool visible = columFlags.value(QString("alarm/colum_%1").arg(nColumnIndex)).toBool();
|
||
ui->aiAlarmTreeView->setColumnHidden(nColumnIndex, visible);
|
||
}
|
||
|
||
loadDeviceGroupFilterWidget();
|
||
if(m_pDeviceModel)
|
||
{
|
||
connect(m_pDeviceModel, &CAlarmDeviceTreeModel::itemCheckStateChanged, this, &CAlarmForm::deviceGroupFilterChanged);
|
||
connect(m_pDeviceModel, &CAlarmDeviceTreeModel::inhibitDevGroupAlm, this, &CAlarmForm::slotInhibitDevGroupAlm);
|
||
connect(CAlarmDataCollect::instance(),&CAlarmDataCollect::sigDevTreeUpdate,m_pDeviceModel,&CAlarmDeviceTreeModel::slotDevTreeUpdate);
|
||
}
|
||
initFilter();
|
||
}
|
||
|
||
void CAlarmForm::setAlarmModel(CAlarmItemModel *model)
|
||
{
|
||
ui->checkBox->setChecked(false);
|
||
ui->checkBox->setHidden(true);
|
||
slot_changePage(0);
|
||
ui->alarmView->horizontalHeader()->setSortIndicator(0, Qt::AscendingOrder);
|
||
m_pModel = model;
|
||
m_delegate = new CAlarmDelegate(m_pModel, ui->alarmView);
|
||
connect(m_delegate,&CAlarmDelegate::openVideo,this,&CAlarmForm::openVideo,Qt::QueuedConnection);
|
||
connect(m_delegate,&CAlarmDelegate::openTrend,this,&CAlarmForm::openTrend,Qt::QueuedConnection);
|
||
connect(CAlarmSetMng::instance(),&CAlarmSetMng::sigLoadConfig,m_delegate,&CAlarmDelegate::slotLoadConfig,Qt::QueuedConnection);
|
||
ui->alarmView->initialize();
|
||
ui->alarmView->setItemDelegate(m_delegate);
|
||
ui->alarmView->setModel(m_pModel);
|
||
|
||
|
||
connect(ui->alarmView->horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), m_pModel, SLOT(sortColumn(int,Qt::SortOrder)));
|
||
ui->confirm->setEnabled(true);
|
||
ui->remove->setEnabled(true);
|
||
//原始告警窗
|
||
|
||
ui->alarmView->setColumnWidth(0, 230);
|
||
ui->alarmView->setColumnWidth(1, 120);
|
||
ui->alarmView->setColumnWidth(2, 150);
|
||
ui->alarmView->setColumnWidth(5, 150);
|
||
ui->alarmView->setColumnWidth(6, 120);
|
||
|
||
|
||
QSettings columFlags("IOT_HMI", "alarm config");
|
||
for(int nColumnIndex(0); nColumnIndex < m_pModel->columnCount() - 1; nColumnIndex++)
|
||
{
|
||
bool visible = columFlags.value(QString("alarm/colum_%1").arg(nColumnIndex)).toBool();
|
||
ui->alarmView->setColumnHidden(nColumnIndex, visible);
|
||
}
|
||
ui->alarmView->setColumnHidden(m_pModel->columnCount() - 1, false);
|
||
|
||
loadDeviceGroupFilterWidget();
|
||
if(m_pDeviceModel)
|
||
{
|
||
connect(m_pDeviceModel, &CAlarmDeviceTreeModel::itemCheckStateChanged, this, &CAlarmForm::deviceGroupFilterChanged);
|
||
connect(m_pDeviceModel, &CAlarmDeviceTreeModel::inhibitDevGroupAlm, this, &CAlarmForm::slotInhibitDevGroupAlm);
|
||
connect(CAlarmDataCollect::instance(),&CAlarmDataCollect::sigDevTreeUpdate,m_pDeviceModel,&CAlarmDeviceTreeModel::slotDevTreeUpdate);
|
||
}
|
||
initFilter();
|
||
}
|
||
|
||
void CAlarmForm::updateView()
|
||
{
|
||
updateRowTips();
|
||
updateDeviceGroupHiddenState();
|
||
}
|
||
|
||
void CAlarmForm::updateFilter()
|
||
{
|
||
bool isLevelFilter;
|
||
QList<int> levelFilter;
|
||
bool isLocationFilter;
|
||
QList<int> locationFilter;
|
||
bool isRegionFilter;
|
||
QList<int> regionFilter;
|
||
bool isAlarmStatusFilter; //告警状态过滤
|
||
QList<int> typeFilter;
|
||
bool deviceTypeFilter;
|
||
QString subSystem;
|
||
QString deviceType;
|
||
bool keywordFilter;
|
||
QString keyword;
|
||
bool isTimeFilterEnable;
|
||
QDateTime startTime;
|
||
QDateTime endTime;
|
||
bool isStateFilterEnable;
|
||
bool isConfirm;
|
||
bool isReturnFilterEnable;
|
||
bool isReturn;
|
||
|
||
CAlarmFilterDialog filterDlg;
|
||
m_pModel->getFilter(isLevelFilter, levelFilter,
|
||
isLocationFilter, locationFilter,
|
||
isRegionFilter, regionFilter,
|
||
isAlarmStatusFilter, typeFilter,
|
||
deviceTypeFilter, subSystem, deviceType,
|
||
keywordFilter, keyword,
|
||
isTimeFilterEnable, startTime, endTime,
|
||
isStateFilterEnable, isConfirm,
|
||
isReturnFilterEnable,isReturn);
|
||
filterDlg.initialize();
|
||
filterDlg.setLevelFilterEnable(isLevelFilter);
|
||
filterDlg.setLevelFilter(levelFilter);
|
||
filterDlg.setLocationFilterEnable(isLocationFilter);
|
||
filterDlg.setLocationFilter(locationFilter);
|
||
filterDlg.setRegionFilterEnable(isRegionFilter);
|
||
filterDlg.setRegionFilter(regionFilter);
|
||
filterDlg.setAlarmStatusFilterEnable(isAlarmStatusFilter);
|
||
filterDlg.setAlarmStatusFilter(typeFilter);
|
||
filterDlg.setDeviceFilterEnable(deviceTypeFilter);
|
||
filterDlg.setSubSystem(subSystem);
|
||
filterDlg.setDeviceType(deviceType);
|
||
filterDlg.setkeyWordFilterEnable(keywordFilter);
|
||
filterDlg.setkeyWordFilteContent(keyword);
|
||
filterDlg.setTimeFilterEnable(isTimeFilterEnable);
|
||
filterDlg.setStartTimeFilter(startTime);
|
||
filterDlg.setEndTimeFilter(endTime);
|
||
filterDlg.setStateFilterEnable(isStateFilterEnable);
|
||
filterDlg.setStateFilter(isConfirm);
|
||
filterDlg.setReturnFilterEnable(isReturnFilterEnable);
|
||
filterDlg.setReturnFilter(isReturn);
|
||
connect(&filterDlg, SIGNAL(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)),
|
||
this, SLOT(slot_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)));
|
||
filterDlg.exec();
|
||
}
|
||
|
||
void CAlarmForm::deviceGroupFilterChanged(const QString &device, const bool &checked)
|
||
{
|
||
if(checked)
|
||
{
|
||
m_pModel->removeDeviceGroupFilter(device);
|
||
if(m_treeModel)
|
||
{
|
||
m_treeModel->removeDeviceGroupFilter(device);
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
m_pModel->addDeviceGroupFilter(device);
|
||
if(m_treeModel)
|
||
{
|
||
m_treeModel->addDeviceGroupFilter(device);
|
||
}
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::slot_changePage(int i)
|
||
{
|
||
Q_UNUSED(i)
|
||
if(!ui->checkBox->isChecked())
|
||
{
|
||
ui->stackedWidget->setCurrentIndex(0);
|
||
ui->aiAlarmTreeView->setUpdatesEnabled(false);
|
||
ui->alarmView->setUpdatesEnabled(true);
|
||
ui->inhiAlarm->setEnabled(true);
|
||
}else
|
||
{
|
||
ui->stackedWidget->setCurrentIndex(1);
|
||
ui->alarmView->setUpdatesEnabled(false);
|
||
ui->aiAlarmTreeView->setUpdatesEnabled(true);
|
||
ui->inhiAlarm->setEnabled(false);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::slot_updateFilter(bool isLevelFilter, QList<int> listLevel, bool isLocationFilter, QList<int> listLocation, bool isRegionFilter, QList<int> listRegion, bool isAlarmTypeFilter, QList<int> listAlarmStatus,
|
||
bool isDeviceTypeFilter, QString subSystem, QString deviceType, bool isKeywordFilterEnable, QString keyword, bool isTimeFilter, QDateTime startTime, QDateTime endTime, bool isConfirmFilter, bool confirm, bool isReturnFilter, bool isReturn)
|
||
{
|
||
m_pModel->setFilter(isLevelFilter, listLevel, isLocationFilter, listLocation, isRegionFilter, listRegion, isAlarmTypeFilter, listAlarmStatus, isDeviceTypeFilter, subSystem, deviceType, isKeywordFilterEnable, keyword, isTimeFilter, startTime, endTime, isConfirmFilter, confirm,isReturnFilter,isReturn);
|
||
if(m_treeModel)
|
||
{
|
||
m_treeModel->setFilter(isLevelFilter, listLevel, isLocationFilter, listLocation, isRegionFilter, listRegion, isAlarmTypeFilter, listAlarmStatus, isDeviceTypeFilter, subSystem, deviceType, isKeywordFilterEnable, keyword, isTimeFilter, startTime, endTime, isConfirmFilter, confirm,isReturnFilter,isReturn);
|
||
}
|
||
//设置下拉框的值
|
||
setLevelComboBox(isLevelFilter,listLevel);
|
||
setLocationComboBox(isLocationFilter,listLocation);
|
||
setAlarmStatusComboBox(isAlarmTypeFilter,listAlarmStatus);
|
||
setAlarmTimeLineEdit(isTimeFilter, startTime, endTime);
|
||
}
|
||
|
||
void CAlarmForm::slot_removeAlarm()
|
||
{
|
||
updateAlarmOperatePerm();
|
||
if(!ui->checkBox->isChecked())
|
||
{
|
||
removeAlarm0();
|
||
}else
|
||
{
|
||
removeAlarm1();
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::slot_confirmAlarm()
|
||
{
|
||
updateAlarmOperatePerm();
|
||
if(!ui->checkBox->isChecked())
|
||
{
|
||
confirmAlarm0();
|
||
}else
|
||
{
|
||
confirmAlarm1();
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::slot_showInhibitAlarm()
|
||
{
|
||
CAlarmInhibitDialog dlg;
|
||
QList<AlarmMsgPtr> almList;
|
||
CAlarmMsgManage::instance()->getAllInhibitAlm(almList);
|
||
|
||
dlg.setInhibitAlarmList(almList);
|
||
connect(&dlg, &CAlarmInhibitDialog::removeInhibitAlarmList, this, &CAlarmForm::removeInhibitAlarm);
|
||
dlg.exec();
|
||
|
||
}
|
||
|
||
void CAlarmForm::slot_showShiledAlarm()
|
||
{
|
||
CAlarmShiledDialog dlg;
|
||
dlg.exec();
|
||
}
|
||
|
||
void CAlarmForm::slot_showColorSet()
|
||
{
|
||
CAlarmSetDlg dlg;
|
||
dlg.exec();
|
||
}
|
||
|
||
void CAlarmForm::removeInhibitAlarm(QList<AlarmMsgPtr> alarmList)
|
||
{
|
||
foreach (AlarmMsgPtr alm, alarmList)
|
||
{
|
||
CAlarmMsgManage::instance()->removeInhibitTag(alm->key_id_tag);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::searchDeviceName()
|
||
{
|
||
QItemSelection selection;
|
||
QString content = m_pSearchTextEdit->text();
|
||
ui->deviceView->selectionModel()->select(selection, QItemSelectionModel::Clear);
|
||
if(content.isEmpty())
|
||
{
|
||
return;
|
||
}
|
||
const QHash< QString, QModelIndex > &indexNameList = m_pDeviceModel->indexNameList();
|
||
QHash< QString, QModelIndex >::const_iterator iter = indexNameList.constBegin();
|
||
while (iter != indexNameList.constEnd())
|
||
{
|
||
if(ui->deviceView->isRowHidden(iter.value().row(), iter.value().parent()))
|
||
{
|
||
iter++;
|
||
continue;
|
||
}
|
||
if(iter.key().section(".", 1).contains(content, Qt::CaseInsensitive))
|
||
{
|
||
selection.append(QItemSelectionRange(iter.value(), iter.value()));
|
||
selection.append(QItemSelectionRange(iter.value().parent(), iter.value().parent()));
|
||
}
|
||
iter++;
|
||
}
|
||
ui->deviceView->selectionModel()->select(selection, QItemSelectionModel::Select);
|
||
}
|
||
|
||
void CAlarmForm::updateRowTips()
|
||
{
|
||
if(!ui->checkBox->isChecked())
|
||
{
|
||
if(m_pModel)
|
||
{
|
||
ui->alarmView->viewport()->update();
|
||
ui->showRow->setText(QString::number(m_pModel->rowCount()));
|
||
int nNumber = m_pModel->filterCount();
|
||
if(nNumber<0) nNumber = 0 ;
|
||
ui->filterRow->setText(QString::number(nNumber));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if(m_treeModel)
|
||
{
|
||
ui->aiAlarmTreeView->viewport()->update();
|
||
int showNum = m_treeModel->getShowNum();
|
||
int showAiNum = m_treeModel->getShowAi();
|
||
int filterAi = CAlarmMsgManage::instance()->getAiCount() -showAiNum;
|
||
int showTotal = CAlarmMsgManage::instance()->getAlmTotal();
|
||
ui->showRow->setText(QString("%1/%2").arg(showNum).arg(showAiNum));
|
||
int nNumber = showTotal - showNum;
|
||
if(nNumber<0) nNumber = 0 ;
|
||
if(filterAi<0) filterAi = 0;
|
||
ui->filterRow->setText(QString("%1/%2").arg(nNumber).arg(filterAi));
|
||
}
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::print()
|
||
{
|
||
//QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),"",tr("(*.pdf *)"));
|
||
QString fileName=QFileDialog::getSaveFileName(this,tr("Save File"),QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation),"*.xlsx");//获取保存路径*.xls
|
||
if(!ui->checkBox->isChecked())
|
||
{
|
||
print0(fileName);
|
||
}else
|
||
{
|
||
print1(fileName);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::stateChanged1(int state)
|
||
{
|
||
Q_UNUSED(state)
|
||
QString strText("");
|
||
m_priorityList.clear();
|
||
int nCount = m_pListWidget1->count();
|
||
for (int i = 0; i < nCount; ++i)
|
||
{
|
||
QListWidgetItem *pItem = m_pListWidget1->item(i);
|
||
QWidget *pWidget = m_pListWidget1->itemWidget(pItem);
|
||
CMyCheckBox *pCheckBox = (CMyCheckBox *)pWidget;
|
||
if (pCheckBox->isChecked())
|
||
{
|
||
int nData = pItem->data(Qt::UserRole).toInt();
|
||
QString strtext = pCheckBox->text();
|
||
strText.append(strtext).append(" ");
|
||
m_priorityList.append(nData);
|
||
}
|
||
}
|
||
if (!strText.isEmpty())
|
||
{
|
||
m_strText1 = strText;
|
||
m_pLineEdit1->setText(strText);
|
||
}
|
||
else
|
||
{
|
||
m_pLineEdit1->clear();
|
||
m_strText1 = tr("请选择优先级");
|
||
m_pLineEdit1->setText(tr("请选择优先级"));
|
||
}
|
||
bool isCheck = false;
|
||
if(m_priorityList.size() > 0)
|
||
{
|
||
isCheck = true;
|
||
}
|
||
if(m_pModel)
|
||
{
|
||
m_pModel->setPriorityFilter(isCheck,m_priorityList);
|
||
}
|
||
if(m_treeModel)
|
||
{
|
||
m_treeModel->setPriorityFilter(isCheck,m_priorityList);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::stateChanged2(int state)
|
||
{
|
||
Q_UNUSED(state)
|
||
QString strText("");
|
||
m_locationList.clear();
|
||
int nCount = m_pListWidget2->count();
|
||
for (int i = 0; i < nCount; ++i)
|
||
{
|
||
QListWidgetItem *pItem = m_pListWidget2->item(i);
|
||
QWidget *pWidget = m_pListWidget2->itemWidget(pItem);
|
||
CMyCheckBox *pCheckBox = (CMyCheckBox *)pWidget;
|
||
if (pCheckBox->isChecked())
|
||
{
|
||
int nData = pItem->data(Qt::UserRole).toInt();
|
||
QString strtext = pCheckBox->text();
|
||
strText.append(strtext).append(" ");
|
||
m_locationList.append(nData);
|
||
}
|
||
}
|
||
if (!strText.isEmpty())
|
||
{
|
||
m_strText2 = strText;
|
||
m_pLineEdit2->setText(strText);
|
||
}
|
||
else
|
||
{
|
||
m_pLineEdit2->clear();
|
||
m_strText2 = tr("请选择位置");
|
||
m_pLineEdit2->setText(tr("请选择位置"));
|
||
}
|
||
bool isCheck = false;
|
||
if(m_locationList.size() > 0)
|
||
{
|
||
isCheck = true;
|
||
}
|
||
if(m_pModel)
|
||
{
|
||
m_pModel->setLocationFilter(isCheck,m_locationList);
|
||
}
|
||
if(m_treeModel)
|
||
{
|
||
m_treeModel->setLocationFilter(isCheck,m_locationList);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::stateChanged3(int state)
|
||
{
|
||
Q_UNUSED(state)
|
||
QString strText("");
|
||
m_alarmStatusList.clear();
|
||
bool other = false;
|
||
int nCount = m_pListWidget3->count();
|
||
for (int i = 0; i < nCount; ++i)
|
||
{
|
||
QListWidgetItem *pItem = m_pListWidget3->item(i);
|
||
QWidget *pWidget = m_pListWidget3->itemWidget(pItem);
|
||
CMyCheckBox *pCheckBox = (CMyCheckBox *)pWidget;
|
||
if (pCheckBox->isChecked())
|
||
{
|
||
int nData = pItem->data(Qt::UserRole).toInt();
|
||
if(nData == OTHERSTATUS)
|
||
{
|
||
other = true;
|
||
}
|
||
QString strtext = pCheckBox->text();
|
||
strText.append(strtext).append(" ");
|
||
m_alarmStatusList.append(nData);
|
||
}
|
||
}
|
||
if (!strText.isEmpty())
|
||
{
|
||
m_strText3 = strText;
|
||
m_pLineEdit3->setText(strText);
|
||
}
|
||
else
|
||
{
|
||
m_pLineEdit3->clear();
|
||
m_strText3 = tr("请选择告警状态");
|
||
m_pLineEdit3->setText(tr("请选择告警状态"));
|
||
}
|
||
bool isCheck = false;
|
||
if(m_alarmStatusList.size() > 0)
|
||
{
|
||
isCheck = true;
|
||
}
|
||
if(m_pModel)
|
||
{
|
||
m_pModel->setAlarmTypeFilter(isCheck,m_alarmStatusList,other);
|
||
}
|
||
if(m_treeModel)
|
||
{
|
||
m_treeModel->setAlarmTypeFilter(isCheck,m_alarmStatusList,other);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::textChanged1(const QString &text)
|
||
{
|
||
Q_UNUSED(text)
|
||
m_pLineEdit1->setText(m_strText1);
|
||
}
|
||
|
||
void CAlarmForm::textChanged2(const QString &text)
|
||
{
|
||
Q_UNUSED(text)
|
||
m_pLineEdit2->setText(m_strText2);
|
||
}
|
||
|
||
void CAlarmForm::textChanged3(const QString &text)
|
||
{
|
||
Q_UNUSED(text)
|
||
m_pLineEdit3->setText(m_strText3);
|
||
}
|
||
|
||
void CAlarmForm::myCalendarHide(QDate startTime,QDate endTime)
|
||
{
|
||
ui->lineEdit->setText(startTime.toString("yyyy-MM-dd") +"~"+endTime.toString("yyyy-MM-dd"));
|
||
//开始过滤
|
||
bool isCheck = true;
|
||
if(m_pModel)
|
||
{
|
||
m_pModel->setAlarmTimeFilter(isCheck,startTime,endTime);
|
||
}
|
||
if(m_treeModel)
|
||
{
|
||
m_treeModel->setAlarmTimeFilter(isCheck,startTime,endTime);
|
||
}
|
||
m_timeMenu->hide();
|
||
}
|
||
|
||
void CAlarmForm::myCalendarShow()
|
||
{
|
||
QPoint point(QCursor::pos().x()-260,QCursor::pos().y()+15);
|
||
m_timeMenu->move(point);
|
||
m_timeMenu->show();
|
||
}
|
||
|
||
void CAlarmForm::cancleTimeFilter()
|
||
{
|
||
ui->lineEdit->setText(tr("请选择时间"));
|
||
//取消过滤
|
||
bool isCheck = false;
|
||
if(m_pModel)
|
||
{
|
||
m_pModel->setAlarmTimeFilter(isCheck);
|
||
}
|
||
if(m_treeModel)
|
||
{
|
||
m_treeModel->setAlarmTimeFilter(isCheck);
|
||
}
|
||
|
||
m_timeMenu->hide();
|
||
}
|
||
|
||
void CAlarmForm::aiAlmDoubleClicked(const QModelIndex &index)
|
||
{
|
||
if(m_treeModel == NULL)
|
||
{
|
||
return ;
|
||
}
|
||
if(!index.isValid())
|
||
{
|
||
return ;
|
||
}
|
||
CAiAlarmTreeItem *item =static_cast<CAiAlarmTreeItem*>(index.internalPointer());
|
||
if(item->isAi())
|
||
{
|
||
AiAlarmMsgPtr aiPtr;
|
||
if(item->getAiPtr(aiPtr))
|
||
{
|
||
CDisposalPlanDialog dialog(aiPtr);
|
||
dialog.exec();
|
||
}else
|
||
{
|
||
LOGERROR("aiAlmDoubleClicked():标识符错误!");
|
||
}
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::printMess(QString fileName)
|
||
{
|
||
Q_UNUSED(fileName);
|
||
QMessageBox::information( 0, tr("提示"), tr("导出成功"));
|
||
}
|
||
|
||
void CAlarmForm::slotInhibitDevGroupAlm(const QString &strDevg, int nDomainId, int nLocationId, int nSubsystemId, int nRegionId)
|
||
{
|
||
if(!permCheck(nLocationId,nRegionId))
|
||
{
|
||
return;
|
||
}
|
||
QList<QString> pointList;
|
||
if(!CAlarmBaseData::instance()->queryAllPointDevGroup(nDomainId, nSubsystemId, strDevg, pointList))
|
||
{
|
||
QMessageBox::information(this, tr("提示"), tr("禁止告警失败,请检查实时库连接!"));
|
||
return;
|
||
}
|
||
for(int n(0); n<pointList.length(); n++){
|
||
AlarmMsgPtr almMsgPtr(new CAlarmMsgInfo);
|
||
almMsgPtr->domain_id = nDomainId;
|
||
almMsgPtr->location_id = nLocationId;
|
||
almMsgPtr->sub_system = nSubsystemId;
|
||
almMsgPtr->key_id_tag = pointList[n];
|
||
inhibitAlm(almMsgPtr);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::slotInhibitAlarm()
|
||
{
|
||
if(!m_pModel)
|
||
{
|
||
return;
|
||
}
|
||
QModelIndex index = ui->alarmView->currentIndex();
|
||
if(!index.isValid())
|
||
{
|
||
QMessageBox::information(this, tr("提示"), tr("请选择一条告警!"));
|
||
return;
|
||
}
|
||
AlarmMsgPtr alm = m_pModel->getAlarmInfo(index);
|
||
if(!permCheck(alm->location_id,alm->region_id))
|
||
{
|
||
return;
|
||
}
|
||
inhibitAlm(alm);
|
||
}
|
||
|
||
void CAlarmForm::contextMenuEvent(QContextMenuEvent *event)
|
||
{
|
||
if(!m_isNormal)
|
||
{
|
||
return ;
|
||
}
|
||
updateAlarmOperatePerm();
|
||
if(ui->stackedWidget->currentIndex() == 0)
|
||
{
|
||
contextMenuStack0Event(event);
|
||
}else if(ui->stackedWidget->currentIndex() == 1)
|
||
{
|
||
contextMenuStack1Event(event);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::contextMenuStack0Event(QContextMenuEvent *event)
|
||
{
|
||
QWidget::contextMenuEvent(event);
|
||
if(!m_pModel)
|
||
{
|
||
return;
|
||
}
|
||
if(event->pos().x() < ui->alarmView->pos().x())
|
||
{
|
||
return;
|
||
}
|
||
QRect headerRect = ui->alarmView->horizontalHeader()->rect();
|
||
headerRect.moveTopLeft(ui->alarmView->mapTo(this, QPoint()));
|
||
if(headerRect.contains(event->pos()))
|
||
{
|
||
QMenu columnMenu(this);
|
||
|
||
for(int nColumnIndex(0); nColumnIndex < m_pModel->columnCount()-1; nColumnIndex++)
|
||
{
|
||
QAction * action = columnMenu.addAction(m_pModel->headerData(nColumnIndex, Qt::Horizontal, Qt::DisplayRole).toString());
|
||
action->setCheckable(true);
|
||
action->setChecked(!ui->alarmView->isColumnHidden(nColumnIndex));
|
||
connect(action, &QAction::triggered, [=](){
|
||
ui->alarmView->setColumnHidden(nColumnIndex, !action->isChecked());
|
||
ui->aiAlarmTreeView->setColumnHidden(nColumnIndex, !action->isChecked());
|
||
QSettings columFlags("IOT_HMI", "alarm config");
|
||
columFlags.setValue(QString("alarm/colum_%1").arg(nColumnIndex), !action->isChecked());
|
||
});
|
||
}
|
||
columnMenu.exec(QCursor::pos());
|
||
}
|
||
else
|
||
{
|
||
QModelIndex index_ = ui->alarmView->indexAt(ui->alarmView->mapFromGlobal(event->globalPos() - QPoint(0, headerRect.height())));
|
||
if(!index_.isValid())
|
||
{
|
||
return;
|
||
}
|
||
QModelIndexList indexLists = ui->alarmView->selectionModel()->selectedIndexes();
|
||
//判断右键位置是否在选中区
|
||
QModelIndex index = ui->alarmView->currentIndex();
|
||
if(!indexLists.contains(index))
|
||
{
|
||
ui->alarmView->clearSelection();
|
||
ui->alarmView->setCurrentIndex(index);
|
||
}
|
||
AlarmMsgPtr alm = m_pModel->getAlarmInfo(index);
|
||
QMenu menu(this);
|
||
QAction * selectAction = menu.addAction(tr("全选"));
|
||
connect(selectAction, &QAction::triggered, [=](){ui->alarmView->selectAll();});
|
||
QAction * cancleAction = menu.addAction(tr("全不选"));
|
||
connect(cancleAction,&QAction::triggered,[=](){ui->alarmView->clearSelection();});
|
||
menu.addSeparator();
|
||
|
||
QAction * confirmAction = menu.addAction(tr("确认"));
|
||
connect(confirmAction,&QAction::triggered,[=](){
|
||
rightConfirm0();
|
||
});
|
||
QAction * removeAction = menu.addAction(tr("删除"));
|
||
connect(removeAction,&QAction::triggered,[=](){
|
||
rightRemove0();
|
||
});
|
||
|
||
menu.addSeparator();
|
||
|
||
// QAction * trendAction = menu.addAction(tr("趋势"));
|
||
|
||
// connect(trendAction,&QAction::triggered,[=](){
|
||
// rightTrend0();
|
||
// });
|
||
if(alm->m_needVideoAlm)
|
||
{
|
||
QAction * videoAction = menu.addAction(tr("视频"));
|
||
connect(videoAction,&QAction::triggered,[=](){
|
||
rightVideo0();
|
||
});
|
||
}
|
||
// QAction * faultRecordAction = menu.addAction(tr("故障录播"));
|
||
// connect(faultRecordAction,&QAction::triggered,[=](){
|
||
// rightFaultRecord0();
|
||
// });
|
||
|
||
|
||
if(m_isNeedAccidentReview)
|
||
{
|
||
QAction * accidentReviewAction = menu.addAction(tr("事故追忆"));
|
||
connect(accidentReviewAction,&QAction::triggered,[=](){
|
||
rightAccidentReview0();
|
||
});
|
||
}
|
||
|
||
QAction * InhibitAction = menu.addAction(tr("禁止告警"));
|
||
connect(InhibitAction, &QAction::triggered, [=](){
|
||
// bool isContains = false;
|
||
// QList<AlarmMsgPtr> almList;
|
||
// CAlarmMsgManage::instance()->getAllInhibitAlm(almList);
|
||
if(!permCheck(alm->location_id,alm->region_id))
|
||
{
|
||
return;
|
||
}
|
||
inhibitAlm(alm);
|
||
// foreach (AlarmMsgPtr alarm, almList)
|
||
// {
|
||
// if(alarm->key_id_tag == alm->key_id_tag)
|
||
// {
|
||
// isContains = true;
|
||
// break;
|
||
// }
|
||
// }
|
||
// if(isContains)
|
||
// {
|
||
// QMessageBox::warning(this, tr("警告"), tr("当前测点告警已禁止,无需重复禁止!"), QMessageBox::Ok);
|
||
// }
|
||
// else
|
||
// {
|
||
// CAlarmMsgManage::instance()->addInhibitAlm(alm);
|
||
// }
|
||
});
|
||
|
||
menu.exec(QCursor::pos());
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::contextMenuStack1Event(QContextMenuEvent *event)
|
||
{
|
||
QWidget::contextMenuEvent(event);
|
||
if(!m_treeModel)
|
||
{
|
||
return;
|
||
}
|
||
if(event->pos().x() < ui->aiAlarmTreeView->pos().x())
|
||
{
|
||
return;
|
||
}
|
||
QRect headerRect = ui->aiAlarmTreeView->header()->rect();
|
||
headerRect.moveTopLeft(ui->aiAlarmTreeView->mapTo(this, QPoint()));
|
||
if(headerRect.contains(event->pos()))
|
||
{
|
||
QMenu columnMenu(this);
|
||
|
||
for(int nColumnIndex(0); nColumnIndex < m_treeModel->columnCount()-1; nColumnIndex++)
|
||
{
|
||
QAction * action = columnMenu.addAction(m_treeModel->headerData(nColumnIndex, Qt::Horizontal, Qt::DisplayRole).toString());
|
||
action->setCheckable(true);
|
||
action->setChecked(!ui->aiAlarmTreeView->isColumnHidden(nColumnIndex));
|
||
connect(action, &QAction::triggered, [=](){
|
||
ui->alarmView->setColumnHidden(nColumnIndex, !action->isChecked());
|
||
ui->aiAlarmTreeView->setColumnHidden(nColumnIndex, !action->isChecked());
|
||
QSettings columFlags("IOT_HMI", "alarm config");
|
||
columFlags.setValue(QString("alarm/colum_%1").arg(nColumnIndex), !action->isChecked());
|
||
});
|
||
}
|
||
columnMenu.exec(QCursor::pos());
|
||
}else
|
||
{
|
||
QModelIndex index_ = ui->aiAlarmTreeView->indexAt(ui->aiAlarmTreeView->mapFromGlobal(event->globalPos() - QPoint(0, headerRect.height())));
|
||
if(!index_.isValid())
|
||
{
|
||
return;
|
||
}
|
||
QMenu menu(this);
|
||
QModelIndex index = ui->aiAlarmTreeView->currentIndex();
|
||
if(!index.isValid())
|
||
{
|
||
return ;
|
||
}
|
||
QModelIndexList indexLists = ui->aiAlarmTreeView->selectionModel()->selectedIndexes();
|
||
|
||
//判断右键位置是否在选中区
|
||
if(!indexLists.contains(index))
|
||
{
|
||
ui->aiAlarmTreeView->clearSelection();
|
||
ui->aiAlarmTreeView->setCurrentIndex(index);
|
||
}
|
||
QAction * selectAction = menu.addAction(tr("全选"));
|
||
connect(selectAction,&QAction::triggered,[=](){ui->aiAlarmTreeView->selectAll();});
|
||
QAction * cancleAction = menu.addAction(tr("全不选"));
|
||
connect(cancleAction,&QAction::triggered,[=](){ui->aiAlarmTreeView->clearSelection();});
|
||
menu.addSeparator();
|
||
QAction * confirmAction = menu.addAction(tr("确认"));
|
||
connect(confirmAction,&QAction::triggered,[=](){
|
||
rightConfirm1();
|
||
});
|
||
QAction * removeAction = menu.addAction(tr("删除"));
|
||
connect(removeAction,&QAction::triggered,[=](){
|
||
rightRemove1();
|
||
});
|
||
menu.addSeparator();
|
||
QAction * mergeAction = menu.addAction(tr("合并"));
|
||
connect(mergeAction,&QAction::triggered,[=](){
|
||
rightMerge1();
|
||
});
|
||
QAction * seprAction = menu.addAction(tr("分离"));
|
||
connect(seprAction,&QAction::triggered,[=](){
|
||
rightSepr1();
|
||
});
|
||
menu.addSeparator();
|
||
//讨论删除右键趋势2020-6-17 jxd sjq zlx
|
||
|
||
// QAction * trendAction = menu.addAction(tr("趋势"));
|
||
// connect(trendAction,&QAction::triggered,[=](){
|
||
// rightTrend1();
|
||
// });
|
||
|
||
CAiAlarmTreeItem *item = static_cast<CAiAlarmTreeItem*>(index.internalPointer());
|
||
if(!item->isAi())
|
||
{
|
||
AlarmMsgPtr ptr = NULL;
|
||
if(item->getPtr(ptr))
|
||
{
|
||
if(ptr->m_needVideoAlm)
|
||
{
|
||
QAction * videoAction = menu.addAction(tr("视频"));
|
||
connect(videoAction,&QAction::triggered,[=](){
|
||
rightVideo1();
|
||
});
|
||
}
|
||
}
|
||
}
|
||
// QAction * faultRecordAction = menu.addAction(tr("故障录播"));
|
||
// connect(faultRecordAction,&QAction::triggered,[=](){
|
||
// rightFaultRecord1();
|
||
// });
|
||
if(m_isNeedAccidentReview)
|
||
{
|
||
QAction * accidentReviewAction = menu.addAction(tr("事故追忆"));
|
||
connect(accidentReviewAction,&QAction::triggered,[=](){
|
||
rightAccidentReview1();
|
||
});
|
||
}
|
||
menu.exec(QCursor::pos());
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::loadDeviceGroupFilterWidget()
|
||
{
|
||
if(!m_pModel)
|
||
{
|
||
return;
|
||
}
|
||
QMap< int, QVector< SDevGroupInfo > > locationInfos;
|
||
|
||
QList<int> locationList = CAlarmBaseData::instance()->getPermLocationOrder();
|
||
|
||
if(m_pReadDb->isOpen())
|
||
{
|
||
for(int nIndex(0); nIndex<locationList.length(); nIndex++)
|
||
{
|
||
QVector< SDevGroupInfo > dev;
|
||
|
||
QSqlQuery query;
|
||
QString sqlSequenceQuery = QString("select tag_name, description,sub_system,region_id from dev_group where location_id = %1;").arg(locationList[nIndex]);
|
||
if(m_pReadDb->execute(sqlSequenceQuery, query))
|
||
{
|
||
while(query.next())
|
||
{
|
||
SDevGroupInfo _stDevGroupInfo;
|
||
_stDevGroupInfo.tag_name = query.value(0).toString();
|
||
_stDevGroupInfo.description = query.value(1).toString();
|
||
_stDevGroupInfo.domain = CAlarmBaseData::instance()->queryDomainIdByLocId(locationList[nIndex]);
|
||
_stDevGroupInfo.location = locationList[nIndex];
|
||
_stDevGroupInfo.sub_system = query.value(2).toInt();
|
||
_stDevGroupInfo.region = query.value(3).toInt();
|
||
dev.push_back(_stDevGroupInfo);
|
||
}
|
||
locationInfos.insert(locationList[nIndex], dev);
|
||
}else
|
||
{
|
||
LOGERROR("load device info error, dbInterface execute failed!");
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
LOGERROR("load deviceGroup info error, database open failed!");
|
||
}
|
||
m_pDeviceModel->removeData();
|
||
m_pDeviceModel->setupModelData(locationInfos,locationList);
|
||
updateDeviceGroupHiddenState();
|
||
ui->deviceView->expandAll();
|
||
}
|
||
|
||
void CAlarmForm::updateDeviceGroupHiddenState()
|
||
{
|
||
QHash<QString, int> listDeviceStatisticalInfo = m_pDeviceModel->getDeviceStatisticalInfo();
|
||
for(int nTopLevelRow(0); nTopLevelRow < m_pDeviceModel->rowCount(); nTopLevelRow++)
|
||
{
|
||
QModelIndex topLevelIndex = m_pDeviceModel->index(nTopLevelRow, 0);
|
||
for(int nChildRow(0); nChildRow < m_pDeviceModel->rowCount(topLevelIndex); nChildRow++)
|
||
{
|
||
CAlarmDeviceTreeItem *item = static_cast<CAlarmDeviceTreeItem*>(m_pDeviceModel->index(nChildRow, 0, topLevelIndex).internalPointer());
|
||
ui->deviceView->setRowHidden(nChildRow, topLevelIndex, !listDeviceStatisticalInfo.value(item->data(Qt::ItemDataRole(TagRole)).toString(), 0));
|
||
}
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::print0(QString fileName)
|
||
{
|
||
if(!fileName.isEmpty() && m_pModel)
|
||
{
|
||
if(!fileName.endsWith(".xlsx",Qt::CaseInsensitive))
|
||
fileName = fileName + ".xlsx";
|
||
emit printExcelAlm(m_pModel,fileName);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::print1(QString fileName)
|
||
{
|
||
if(!fileName.isEmpty() && m_treeModel)
|
||
{
|
||
if(!fileName.endsWith(".xlsx",Qt::CaseInsensitive))
|
||
fileName = fileName + ".xlsx";
|
||
emit printExcel(m_treeModel,fileName);
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::removeAlarm0()
|
||
{
|
||
QModelIndexList modelIndexList = ui->alarmView->selectionModel()->selectedRows(0);
|
||
if(modelIndexList.isEmpty())
|
||
{
|
||
QMessageBox::warning(this, tr("提示"), tr("当前未选中任何项!"), QMessageBox::Ok);
|
||
return;
|
||
}
|
||
QList<AlarmMsgPtr> listInfo = m_pModel->getListShowAlarmInfo();
|
||
//声明告警删除package
|
||
QMap<int, iot_idl::SAlmCltDelAlm *> pkgMap; //Domain-DelPkg;
|
||
int permSkip = -1; //< 不具备确认权限时是否跳过: 0-单步跳过、1-全部跳过
|
||
int unConfirmSkip = -1; //< 未确认告警是否跳过: 0-单步跳过、1-全部跳过
|
||
|
||
QModelIndexList::iterator modelIndexIter = modelIndexList.begin();
|
||
for(;modelIndexIter != modelIndexList.end();modelIndexIter++)
|
||
{
|
||
AlarmMsgPtr info = listInfo.at(modelIndexIter->row());
|
||
//< 权限过滤
|
||
|
||
if(!m_listLocationDelId.contains(info->location_id) || (!m_listRegionDelId.contains(info->region_id) && info->region_id != -1))
|
||
{
|
||
if(1 != permSkip)
|
||
{
|
||
QMessageBox *msgBox = new QMessageBox(this);
|
||
msgBox->setObjectName("msgbox");
|
||
msgBox->setText(tr("当前用户不具备该告警删除操作权限!"));
|
||
msgBox->setInformativeText(tr("是否跳过该项?"));
|
||
QPushButton *skip = msgBox->addButton(tr("跳过"), QMessageBox::ActionRole);
|
||
QPushButton *skipAll = msgBox->addButton(tr("全部跳过"), QMessageBox::AcceptRole);
|
||
msgBox->addButton(tr("取消"), QMessageBox::RejectRole);
|
||
msgBox->setDefaultButton(skip);
|
||
msgBox->exec();
|
||
if (msgBox->clickedButton() == skip)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
permSkip = 0;
|
||
continue;
|
||
}
|
||
else if (msgBox->clickedButton() == skipAll)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
permSkip = 1;
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
|
||
//删除条件
|
||
if(info->logic_state == E_ALS_ALARM || info->logic_state == E_ALS_RETURN)
|
||
{
|
||
if(1 != unConfirmSkip)
|
||
{
|
||
QMessageBox *msgBox = new QMessageBox(this);
|
||
msgBox->setObjectName("msgbox");
|
||
msgBox->setText(tr("包含未确认告警!"));
|
||
msgBox->setInformativeText(tr("是否跳过该项?"));
|
||
QPushButton *skip = msgBox->addButton(tr("跳过"), QMessageBox::ActionRole);
|
||
QPushButton *skipAll = msgBox->addButton(tr("全部跳过"), QMessageBox::AcceptRole);
|
||
msgBox->addButton(tr("取消"), QMessageBox::RejectRole);
|
||
msgBox->setDefaultButton(skip);
|
||
msgBox->exec();
|
||
if (msgBox->clickedButton() == skip)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
unConfirmSkip = 0;
|
||
continue;
|
||
}
|
||
else if (msgBox->clickedButton() == skipAll)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
unConfirmSkip = 1;
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
|
||
//构建告警删除package
|
||
QMap<int, iot_idl::SAlmCltDelAlm *>::iterator it = pkgMap.find(info->domain_id);
|
||
if(it == pkgMap.end())
|
||
{
|
||
iot_idl::SAlmCltDelAlm * pkg = new iot_idl::SAlmCltDelAlm();
|
||
pkg->set_domain_id(info->domain_id);
|
||
pkgMap[info->domain_id] = pkg;
|
||
}
|
||
pkgMap.value(info->domain_id)->add_uuid_base64(info->uuid_base64.toStdString());
|
||
}
|
||
//请求删除
|
||
foreach (iot_idl::SAlmCltDelAlm * pkg, pkgMap)
|
||
{
|
||
if(CAlarmDataCollect::instance()->requestDelAlm(*pkg)!= true)
|
||
{
|
||
LOGERROR("请求删除原始告警失败!");
|
||
}
|
||
}
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
ui->alarmView->setFocus();
|
||
}
|
||
|
||
void CAlarmForm::removeAlarm1()
|
||
{
|
||
if(!m_treeModel)
|
||
{
|
||
return ;
|
||
}
|
||
QModelIndexList modelIndexList = ui->aiAlarmTreeView->selectionModel()->selectedRows(0);
|
||
if(modelIndexList.isEmpty())
|
||
{
|
||
QMessageBox::warning(this, tr("提示"), tr("当前未选中任何项!"), QMessageBox::Ok);
|
||
return;
|
||
}
|
||
QList<AiAlarmMsgPtr> aimsgList; //选中的智能告警
|
||
QList<AlarmMsgPtr> msgList; //选中的原始告警
|
||
//声明智能告警删除package
|
||
QMap<int, iot_idl::SIntelliAlmDel *> aipkgMap; //Domain-DelPkg; ai
|
||
QMap<int, iot_idl::SAlmCltDelAlm *> pkgMap; //Domain-DelPkg; alarm
|
||
int permSkip = -1; //< 不具备确认权限时是否跳过: 0-单步跳过、1-全部跳过
|
||
int unConfirmSkip = -1; //< 未确认告警是否跳过: 0-单步跳过、1-全部跳过
|
||
QModelIndexList::iterator modelIndexIter = modelIndexList.begin();
|
||
for(;modelIndexIter != modelIndexList.end();modelIndexIter++)
|
||
{
|
||
if(!modelIndexIter->isValid())
|
||
{
|
||
continue;
|
||
}
|
||
CAiAlarmTreeItem *item = static_cast<CAiAlarmTreeItem*>(modelIndexIter->internalPointer());
|
||
if(item->isAi())
|
||
{
|
||
AiAlarmMsgPtr ptr = NULL;
|
||
if(item->getAiPtr(ptr))
|
||
{
|
||
aimsgList.append(ptr);
|
||
}
|
||
}else
|
||
{
|
||
if(item->parent() == m_treeModel->getItem())
|
||
{
|
||
AlarmMsgPtr ptr = NULL;
|
||
if(item->getPtr(ptr))
|
||
{
|
||
msgList.append(ptr);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(aimsgList.size() <= 0 && msgList.size() <= 0)
|
||
{
|
||
QMessageBox::warning(this, tr("提示"), tr("当前未选中任何智能告警和未聚类的原始告警!"), QMessageBox::Ok);
|
||
return;
|
||
}
|
||
//处理原始告警
|
||
for(int alarm(0);alarm<msgList.size();alarm++)
|
||
{
|
||
AlarmMsgPtr info = msgList.at(alarm);
|
||
if(!m_listLocationDelId.contains(info->location_id) || (!m_listRegionDelId.contains(info->region_id) && info->region_id != -1))
|
||
{
|
||
if(1 != permSkip)
|
||
{
|
||
QMessageBox *msgBox = new QMessageBox(this);
|
||
msgBox->setObjectName("msgbox");
|
||
msgBox->setText(tr("当前用户不具备该告警删除操作权限!"));
|
||
msgBox->setInformativeText(tr("是否跳过该项?"));
|
||
QPushButton *skip = msgBox->addButton(tr("跳过"), QMessageBox::ActionRole);
|
||
QPushButton *skipAll = msgBox->addButton(tr("全部跳过"), QMessageBox::AcceptRole);
|
||
msgBox->addButton(tr("取消"), QMessageBox::RejectRole);
|
||
msgBox->setDefaultButton(skip);
|
||
msgBox->exec();
|
||
if (msgBox->clickedButton() == skip)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
permSkip = 0;
|
||
continue;
|
||
}
|
||
else if (msgBox->clickedButton() == skipAll)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
permSkip = 1;
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
//删除条件
|
||
if(info->logic_state == E_ALS_ALARM || info->logic_state == E_ALS_RETURN)
|
||
{
|
||
if(1 != unConfirmSkip)
|
||
{
|
||
QMessageBox *msgBox = new QMessageBox(this);
|
||
msgBox->setObjectName("msgbox");
|
||
msgBox->setText(tr("包含未确认告警!"));
|
||
msgBox->setInformativeText(tr("是否跳过该项?"));
|
||
QPushButton *skip = msgBox->addButton(tr("跳过"), QMessageBox::ActionRole);
|
||
QPushButton *skipAll = msgBox->addButton(tr("全部跳过"), QMessageBox::AcceptRole);
|
||
msgBox->addButton(tr("取消"), QMessageBox::RejectRole);
|
||
msgBox->setDefaultButton(skip);
|
||
msgBox->exec();
|
||
if (msgBox->clickedButton() == skip)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
unConfirmSkip = 0;
|
||
continue;
|
||
}
|
||
else if (msgBox->clickedButton() == skipAll)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
unConfirmSkip = 1;
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
//构建告警删除package
|
||
QMap<int, iot_idl::SAlmCltDelAlm *>::iterator it = pkgMap.find(info->domain_id);
|
||
if(it == pkgMap.end())
|
||
{
|
||
iot_idl::SAlmCltDelAlm * pkg = new iot_idl::SAlmCltDelAlm();
|
||
pkg->set_domain_id(info->domain_id);
|
||
pkgMap[info->domain_id] = pkg;
|
||
}
|
||
pkgMap.value(info->domain_id)->add_uuid_base64(info->uuid_base64.toStdString());
|
||
}
|
||
//处理智能告警
|
||
for(int aialarm(0);aialarm<aimsgList.size();aialarm++)
|
||
{
|
||
if(!m_aiOptPerm)
|
||
{
|
||
if(1 != permSkip)
|
||
{
|
||
QMessageBox *msgBox = new QMessageBox(this);
|
||
msgBox->setObjectName("msgbox");
|
||
msgBox->setText(tr("当前用户不具备该告警删除操作权限!"));
|
||
msgBox->setInformativeText(tr("是否跳过该项?"));
|
||
QPushButton *skip = msgBox->addButton(tr("跳过"), QMessageBox::ActionRole);
|
||
QPushButton *skipAll = msgBox->addButton(tr("全部跳过"), QMessageBox::AcceptRole);
|
||
msgBox->addButton(tr("取消"), QMessageBox::RejectRole);
|
||
msgBox->setDefaultButton(skip);
|
||
msgBox->exec();
|
||
if (msgBox->clickedButton() == skip)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
permSkip = 0;
|
||
continue;
|
||
}
|
||
else if (msgBox->clickedButton() == skipAll)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
permSkip = 1;
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
qDeleteAll(aipkgMap);
|
||
aipkgMap.clear();
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
if(CAlarmMsgManage::instance()->ifhaveNotConfirmAlmByuuid(aimsgList.at(aialarm)->uuid_base64))
|
||
{
|
||
if(1 != unConfirmSkip)
|
||
{
|
||
QMessageBox *msgBox = new QMessageBox(this);
|
||
msgBox->setObjectName("msgbox");
|
||
msgBox->setText(tr("包含未确认原始告警告警!"));
|
||
msgBox->setInformativeText(tr("是否跳过该项?"));
|
||
QPushButton *skip = msgBox->addButton(tr("跳过"), QMessageBox::ActionRole);
|
||
QPushButton *skipAll = msgBox->addButton(tr("全部跳过"), QMessageBox::AcceptRole);
|
||
msgBox->addButton(tr("取消"), QMessageBox::RejectRole);
|
||
msgBox->setDefaultButton(skip);
|
||
msgBox->exec();
|
||
if (msgBox->clickedButton() == skip)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
unConfirmSkip = 0;
|
||
continue;
|
||
}
|
||
else if (msgBox->clickedButton() == skipAll)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
unConfirmSkip = 1;
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
qDeleteAll(aipkgMap);
|
||
aipkgMap.clear();
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
int domain_id = aimsgList.at(aialarm)->domain_id;
|
||
QString aiuuid = aimsgList.at(aialarm)->uuid_base64;
|
||
QMap<int, iot_idl::SIntelliAlmDel *>::iterator it = aipkgMap.find(domain_id);
|
||
if(it == aipkgMap.end())
|
||
{
|
||
iot_idl::SIntelliAlmDel * pkg = new iot_idl::SIntelliAlmDel();
|
||
pkg->set_domain_id(domain_id);
|
||
aipkgMap[domain_id] = pkg;
|
||
}
|
||
aipkgMap.value(domain_id)->add_uuid_base64(aiuuid.toStdString());
|
||
}
|
||
//请求删除
|
||
foreach (iot_idl::SAlmCltDelAlm * pkg, pkgMap)
|
||
{
|
||
if(CAlarmDataCollect::instance()->requestDelAlm(*pkg)!= true)
|
||
{
|
||
LOGDEBUG("请求删除原始告警失败!");
|
||
}
|
||
}
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
//请求删除
|
||
foreach (iot_idl::SIntelliAlmDel * pkg, aipkgMap)
|
||
{
|
||
if(CAiAlarmDataCollect::instance()->requestDelAlm(*pkg) != true)
|
||
{
|
||
LOGDEBUG("请求删除智能告警失败!");
|
||
}
|
||
}
|
||
qDeleteAll(aipkgMap);
|
||
aipkgMap.clear();
|
||
ui->aiAlarmTreeView->setFocus();
|
||
}
|
||
|
||
void CAlarmForm::confirmAlarm0()
|
||
{
|
||
LOGINFO("开始确认告警");
|
||
QModelIndexList modelIndexList = ui->alarmView->selectionModel()->selectedRows(0);
|
||
if(modelIndexList.isEmpty())
|
||
{
|
||
QMessageBox::warning(this, tr("提示"), tr("当前未选中任何项!"), QMessageBox::Ok);
|
||
return;
|
||
}
|
||
QList<AlarmMsgPtr> listInfo = m_pModel->getListShowAlarmInfo();
|
||
if(listInfo.isEmpty())
|
||
{
|
||
return;
|
||
}
|
||
|
||
//构建告警确认package
|
||
QMap<QString,AlarmMsgPtr> msgMap; //要确认的告警
|
||
QMap<QString, iot_idl::SAlmCltCfmAlm *> pkgMap; //Domain-DelPkg;
|
||
|
||
int permSkip = -1; //< 不具备确认权限时是否跳过: 0-单步跳过、1-全部跳过
|
||
QModelIndexList::iterator modelIndexIter = modelIndexList.begin();
|
||
for(;modelIndexIter != modelIndexList.end();modelIndexIter++)
|
||
{
|
||
AlarmMsgPtr info = listInfo.at(modelIndexIter->row());
|
||
if(info->logic_state == E_ALS_ALARM_CFM || info->logic_state == E_ALS_RETURN_CFM ||
|
||
info->logic_state == E_ALS_ALARM_CFM_DEL || info->logic_state == E_ALS_RETURN_CFM_DEL )
|
||
{
|
||
continue;
|
||
}
|
||
msgMap[info->uuid_base64] = info;
|
||
}
|
||
QMap<QString,AlarmMsgPtr>::iterator almIter = msgMap.begin();
|
||
for(;almIter != msgMap.end();almIter++)
|
||
{
|
||
if(!m_listLocationOptId.contains(almIter.value()->location_id) || (!m_listRegionOptId.contains(almIter.value()->region_id) && almIter.value()->region_id != -1))
|
||
{
|
||
if(1 != permSkip)
|
||
{
|
||
QMessageBox *msgBox = new QMessageBox(this);
|
||
msgBox->setObjectName("msgbox");
|
||
msgBox->setText(tr("当前用户不具备该告警确认操作权限!"));
|
||
msgBox->setInformativeText(tr("是否跳过该项?"));
|
||
QPushButton *skip = msgBox->addButton(tr("跳过"), QMessageBox::ActionRole);
|
||
QPushButton *skipAll = msgBox->addButton(tr("全部跳过"), QMessageBox::AcceptRole);
|
||
msgBox->addButton(tr("取消"), QMessageBox::RejectRole);
|
||
msgBox->setDefaultButton(skip);
|
||
msgBox->exec();
|
||
if (msgBox->clickedButton() == skip)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
permSkip = 0;
|
||
continue;
|
||
}
|
||
else if (msgBox->clickedButton() == skipAll)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
permSkip = 1;
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
|
||
QString key = QString("%1_%2_%3").arg(almIter.value()->domain_id).arg(almIter.value()->alm_type).arg(almIter.value()->app_id);
|
||
QMap<QString, iot_idl::SAlmCltCfmAlm *>::iterator it = pkgMap.find(key);
|
||
if(it == pkgMap.end())
|
||
{
|
||
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(almIter.value()->domain_id);
|
||
pkg->set_app_id(almIter.value()->app_id);
|
||
pkg->set_alm_type(almIter.value()->alm_type);
|
||
pkgMap[key] = pkg;
|
||
}
|
||
pkgMap.value(key)->add_key_id_tag(almIter.value()->key_id_tag.toStdString());
|
||
pkgMap.value(key)->add_time_stamp(almIter.value()->time_stamp);
|
||
pkgMap.value(key)->add_uuid_base64(almIter.value()->uuid_base64.toStdString());
|
||
}
|
||
|
||
//请求确认
|
||
foreach (iot_idl::SAlmCltCfmAlm * pkg, pkgMap)
|
||
{
|
||
if(CAlarmDataCollect::instance()->requestCfmAlm(*pkg) != true)
|
||
{
|
||
LOGERROR("请求确认告警失败!");
|
||
}
|
||
}
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
ui->alarmView->setFocus();
|
||
LOGINFO("结束确认告警");
|
||
}
|
||
|
||
void CAlarmForm::confirmAlarm1()
|
||
{
|
||
if(!m_treeModel)
|
||
{
|
||
return ;
|
||
}
|
||
QModelIndexList modelIndexList = ui->aiAlarmTreeView->selectionModel()->selectedRows(0);
|
||
if(modelIndexList.isEmpty())
|
||
{
|
||
QMessageBox::warning(this, tr("提示"), tr("当前未选中任何项!"), QMessageBox::Ok);
|
||
return;
|
||
}
|
||
QMap<QString,AlarmMsgPtr> msgMap; //要确认的告警
|
||
msgMap.clear();
|
||
//构建告警确认package
|
||
QMap<QString, iot_idl::SAlmCltCfmAlm *> pkgMap; //Domain-DelPkg;
|
||
int permSkip = -1; //< 不具备确认权限时是否跳过: 0-单步跳过、1-全部跳过
|
||
QModelIndexList::iterator modelIndexIter = modelIndexList.begin();
|
||
for(;modelIndexIter != modelIndexList.end();modelIndexIter++)
|
||
{
|
||
if(!modelIndexIter->isValid())
|
||
{
|
||
continue;
|
||
}
|
||
CAiAlarmTreeItem *item = static_cast<CAiAlarmTreeItem*>(modelIndexIter->internalPointer());
|
||
if(item->isAi())
|
||
{
|
||
AiAlarmMsgPtr ptr = NULL;
|
||
if(item->getAiPtr(ptr))
|
||
{
|
||
QList<AlarmMsgPtr> listPtr = item->getChildAlarmPtr();
|
||
for(int x(0);x<listPtr.size();x++)
|
||
{
|
||
if(listPtr.at(x)->logic_state == E_ALS_ALARM_CFM || listPtr.at(x)->logic_state == E_ALS_RETURN_CFM ||
|
||
listPtr.at(x)->logic_state == E_ALS_ALARM_CFM_DEL || listPtr.at(x)->logic_state == E_ALS_RETURN_CFM_DEL )
|
||
{
|
||
continue;
|
||
}
|
||
msgMap[listPtr.at(x)->uuid_base64] = listPtr.at(x);
|
||
}
|
||
}
|
||
}else
|
||
{
|
||
AlarmMsgPtr ptr = NULL;
|
||
if(item->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 )
|
||
{
|
||
continue;
|
||
}
|
||
msgMap[ptr->uuid_base64] = ptr;
|
||
}
|
||
}
|
||
}
|
||
QMap<QString,AlarmMsgPtr>::iterator almIter = msgMap.begin();
|
||
for(;almIter != msgMap.end();almIter++)
|
||
{
|
||
if(!m_listLocationOptId.contains(almIter.value()->location_id) || (!m_listRegionOptId.contains(almIter.value()->region_id) && almIter.value()->region_id != -1))
|
||
{
|
||
if(1 != permSkip)
|
||
{
|
||
QMessageBox *msgBox = new QMessageBox(this);
|
||
msgBox->setObjectName("msgbox");
|
||
msgBox->setText(tr("当前用户不具备该告警确认操作权限!"));
|
||
msgBox->setInformativeText(tr("是否跳过该项?"));
|
||
QPushButton *skip = msgBox->addButton(tr("跳过"), QMessageBox::ActionRole);
|
||
QPushButton *skipAll = msgBox->addButton(tr("全部跳过"), QMessageBox::AcceptRole);
|
||
msgBox->addButton(tr("取消"), QMessageBox::RejectRole);
|
||
msgBox->setDefaultButton(skip);
|
||
msgBox->exec();
|
||
if (msgBox->clickedButton() == skip)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
permSkip = 0;
|
||
continue;
|
||
}
|
||
else if (msgBox->clickedButton() == skipAll)
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
permSkip = 1;
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
delete msgBox;
|
||
msgBox = NULL;
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
QString key = QString("%1_%2_%3").arg(almIter.value()->domain_id).arg(almIter.value()->alm_type).arg(almIter.value()->app_id);
|
||
QMap<QString, iot_idl::SAlmCltCfmAlm *>::iterator it = pkgMap.find(key);
|
||
if(it == pkgMap.end())
|
||
{
|
||
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(almIter.value()->domain_id);
|
||
pkg->set_app_id(almIter.value()->app_id);
|
||
pkg->set_alm_type(almIter.value()->alm_type);
|
||
pkgMap[key] = pkg;
|
||
}
|
||
pkgMap.value(key)->add_key_id_tag(almIter.value()->key_id_tag.toStdString());
|
||
pkgMap.value(key)->add_time_stamp(almIter.value()->time_stamp);
|
||
pkgMap.value(key)->add_uuid_base64(almIter.value()->uuid_base64.toStdString());
|
||
}
|
||
foreach (iot_idl::SAlmCltCfmAlm * pkg, pkgMap)
|
||
{
|
||
if(CAlarmDataCollect::instance()->requestCfmAlm(*pkg) != true)
|
||
{
|
||
LOGERROR("请求确认告警失败!");
|
||
}
|
||
}
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
ui->aiAlarmTreeView->setFocus();
|
||
}
|
||
|
||
void CAlarmForm::rightConfirm0()
|
||
{
|
||
confirmAlarm0();
|
||
}
|
||
|
||
void CAlarmForm::rightConfirm1()
|
||
{
|
||
confirmAlarm1();
|
||
}
|
||
|
||
void CAlarmForm::rightRemove0()
|
||
{
|
||
removeAlarm0();
|
||
}
|
||
|
||
void CAlarmForm::rightRemove1()
|
||
{
|
||
removeAlarm1();
|
||
}
|
||
|
||
void CAlarmForm::rightMerge1()
|
||
{
|
||
if(!m_treeModel)
|
||
{
|
||
return ;
|
||
}
|
||
QModelIndexList indexList = ui->aiAlarmTreeView->selectionModel()->selectedRows(0);
|
||
QList<AiAlarmMsgPtr> aimsgList;
|
||
QList<AlarmMsgPtr> msgList;
|
||
|
||
foreach (QModelIndex modelIndex, indexList)
|
||
{
|
||
if(!modelIndex.isValid())
|
||
{
|
||
continue;
|
||
}
|
||
CAiAlarmTreeItem *item = static_cast<CAiAlarmTreeItem*>(modelIndex.internalPointer());
|
||
if(item->isAi())
|
||
{
|
||
AiAlarmMsgPtr ptr = NULL;
|
||
if(item->getAiPtr(ptr))
|
||
{
|
||
aimsgList.append(ptr);
|
||
}
|
||
}else
|
||
{
|
||
AlarmMsgPtr ptr = NULL;
|
||
if(item->getPtr(ptr))
|
||
{
|
||
msgList.append(ptr);
|
||
}
|
||
}
|
||
}
|
||
QMap<int, iot_idl::SIntelliAlmMerge *> pkgMap;
|
||
QList<AlarmMsgPtr> listPtr;
|
||
listPtr.clear();
|
||
int permSkip = -1;
|
||
if(aimsgList.size() > 0)
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("包含智能告警,无法合并!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("包含智能告警,无法合并!"), QMessageBox::Ok);
|
||
return ;
|
||
}
|
||
|
||
for(int alarmIndex(0);alarmIndex < msgList.size();alarmIndex++)
|
||
{
|
||
if(msgList.at(alarmIndex) != NULL)
|
||
{
|
||
//判断此原始告警是否已经被聚类
|
||
if(CAlarmMsgManage::instance()->isBelongAi(msgList.at(alarmIndex)->uuid_base64))
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("包含已经聚类的原始告警,无法合并!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("包含已经聚类的原始告警,无法合并!"), QMessageBox::Ok);
|
||
return ;
|
||
}
|
||
//判断权限
|
||
if(!m_aiOptPerm)
|
||
{
|
||
if(1 != permSkip)
|
||
{
|
||
QMessageBox *msgBox = new QMessageBox(this);
|
||
msgBox->setObjectName("msgbox");
|
||
msgBox->setText(tr("当前用户无此条原始告警合并权限!"));
|
||
msgBox->setInformativeText(tr("是否跳过该项?"));
|
||
QPushButton *skip = msgBox->addButton(tr("跳过"), QMessageBox::ActionRole);
|
||
QPushButton *skipAll = msgBox->addButton(tr("全部跳过"), QMessageBox::AcceptRole);
|
||
msgBox->addButton(tr("取消"), QMessageBox::RejectRole);
|
||
msgBox->setDefaultButton(skip);
|
||
msgBox->exec();
|
||
if (msgBox->clickedButton() == skip)
|
||
{
|
||
delete msgBox;
|
||
msgBox =NULL;
|
||
permSkip = 0;
|
||
continue;
|
||
}
|
||
else if (msgBox->clickedButton() == skipAll)
|
||
{
|
||
delete msgBox;
|
||
msgBox =NULL;
|
||
permSkip = 1;
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
delete msgBox;
|
||
msgBox =NULL;
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
return;
|
||
}
|
||
}
|
||
}else
|
||
{
|
||
listPtr.append(msgList.at(alarmIndex));
|
||
}
|
||
}
|
||
}
|
||
//过滤后等于0直接返回
|
||
if(listPtr.size() <= 0)
|
||
{
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
return ;
|
||
}
|
||
for(int x(0);x<listPtr.size();x++)
|
||
{
|
||
int32 domain_id = listPtr.at(x)->domain_id;
|
||
if(!pkgMap.keys().contains(domain_id))
|
||
{
|
||
iot_idl::SIntelliAlmMerge *pkg =new iot_idl::SIntelliAlmMerge();
|
||
pkg->set_domain_id(domain_id);
|
||
pkgMap[domain_id] = pkg;
|
||
}
|
||
pkgMap.value(domain_id)->add_raw_alm_uuid(listPtr.at(x)->uuid_base64.toStdString());
|
||
LOGINFO("UUID:%s",listPtr.at(x)->uuid_base64.toStdString().c_str());
|
||
}
|
||
if(pkgMap.size() != 1)
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("包含不同域的原始告警,无法合并!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("包含不同域的原始告警,无法合并!"), QMessageBox::Ok);
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
return ;
|
||
}
|
||
foreach (iot_idl::SIntelliAlmMerge * pkg, pkgMap)
|
||
{
|
||
if(CAiAlarmDataCollect::instance()->requestMergeAlm(*pkg) != true)
|
||
{
|
||
LOGERROR("请求合并告警失败!");
|
||
}
|
||
}
|
||
qDeleteAll(pkgMap);
|
||
pkgMap.clear();
|
||
ui->aiAlarmTreeView->setFocus();
|
||
LOGINFO("合并结束!");
|
||
}
|
||
|
||
void CAlarmForm::rightSepr1()
|
||
{
|
||
if(!m_treeModel)
|
||
{
|
||
return ;
|
||
}
|
||
QModelIndexList indexList = ui->aiAlarmTreeView->selectionModel()->selectedRows(0);
|
||
QList<AiAlarmMsgPtr> aimsgList;
|
||
QList<AlarmMsgPtr> msgList;
|
||
|
||
foreach (QModelIndex modelIndex, indexList)
|
||
{
|
||
if(!modelIndex.isValid())
|
||
{
|
||
continue;
|
||
}
|
||
CAiAlarmTreeItem *item = static_cast<CAiAlarmTreeItem*>(modelIndex.internalPointer());
|
||
if(item->isAi())
|
||
{
|
||
AiAlarmMsgPtr ptr = NULL;
|
||
if(item->getAiPtr(ptr))
|
||
{
|
||
aimsgList.append(ptr);
|
||
}
|
||
}else
|
||
{
|
||
AlarmMsgPtr ptr = NULL;
|
||
if(item->getPtr(ptr))
|
||
{
|
||
msgList.append(ptr);
|
||
}
|
||
}
|
||
}
|
||
if(aimsgList.size() != 0)
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("包含智能告警,无法分离!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("包含智能告警,无法分离!"), QMessageBox::Ok);
|
||
return ;
|
||
}
|
||
if(msgList.size() <= 0)
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("无原始告警,无法分离!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("无原始告警,无法分离!"), QMessageBox::Ok);
|
||
return ;
|
||
}
|
||
QString aiuuid = "";
|
||
if(!CAlarmMsgManage::instance()->getAiuuid(msgList.at(0)->uuid_base64,aiuuid))
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("包含未聚类的原始告警,无法分离!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("包含未聚类的原始告警,无法分离!"), QMessageBox::Ok);
|
||
return ;
|
||
}
|
||
//权限过滤
|
||
if(!m_aiOptPerm)
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("无此条智能告警的编辑权限!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("无此条智能告警的编辑权限!"), QMessageBox::Ok);
|
||
return ;
|
||
}
|
||
//遍历所有原始告警
|
||
for(int index(1);index<msgList.size();index++)
|
||
{
|
||
QString uuid = "";
|
||
if(!CAlarmMsgManage::instance()->getAiuuid(msgList.at(index)->uuid_base64,uuid))
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("包含未聚类的原始告警,无法分离!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("包含未聚类的原始告警,无法分离!"), QMessageBox::Ok);
|
||
return ;
|
||
}
|
||
if(uuid != aiuuid)
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("包含不同智能告警下的原始告警,无法分离!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("包含不同智能告警下的原始告警,无法分离!"), QMessageBox::Ok);
|
||
return ;
|
||
}
|
||
}
|
||
//拼包
|
||
int domain_id = msgList.at(0)->domain_id;
|
||
iot_idl::SIntelliAlmSepr *pkg = new iot_idl::SIntelliAlmSepr();
|
||
pkg->set_domain_id(domain_id);
|
||
for(int index(0);index<msgList.size();index++)
|
||
{
|
||
pkg->add_raw_alm_uuid(msgList.at(index)->uuid_base64.toStdString());
|
||
}
|
||
//发送
|
||
if(CAiAlarmDataCollect::instance()->requestSeprAlm(*pkg) != true)
|
||
{
|
||
LOGERROR("请求分离告警失败!");
|
||
}
|
||
pkg = NULL;
|
||
delete pkg;
|
||
}
|
||
|
||
void CAlarmForm::rightTrend0()
|
||
{
|
||
quint64 time_stamp = 0;
|
||
QModelIndexList modelIndexList = ui->alarmView->selectionModel()->selectedRows(0);
|
||
if(modelIndexList.isEmpty())
|
||
{
|
||
QMessageBox::warning(this, tr("提示"), tr("当前未选中任何项!"), QMessageBox::Ok);
|
||
return;
|
||
}
|
||
QList<AlarmMsgPtr> listInfo = m_pModel->getListShowAlarmInfo();
|
||
QMap<QString,QString> trendMap;
|
||
foreach (QModelIndex index, modelIndexList)
|
||
{
|
||
AlarmMsgPtr info = listInfo.at(index.row());
|
||
if(info->m_tagname_type == E_TAGNAME_ANA || info->m_tagname_type == E_TAGNAME_ACC)
|
||
{
|
||
time_stamp = info->time_stamp;
|
||
trendMap[info->uuid_base64] = info->key_id_tag;
|
||
}
|
||
}
|
||
if(trendMap.size()<= 0)
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("请选中含有趋势的告警(模拟量和累积量)!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("请选中含有趋势的告警(模拟量和累积量)!"), QMessageBox::Ok);
|
||
return ;
|
||
}else
|
||
{
|
||
//发出打开趋势的信号
|
||
emit openTrend(time_stamp,trendMap.values());
|
||
//test(trendMap.values());
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::rightTrend1()
|
||
{
|
||
if(!m_treeModel)
|
||
{
|
||
return ;
|
||
}
|
||
quint64 time_stamp = 0;
|
||
QModelIndexList indexList = ui->aiAlarmTreeView->selectionModel()->selectedRows(0);
|
||
QMap<QString,QString> trendMap;
|
||
foreach (QModelIndex modelIndex, indexList)
|
||
{
|
||
if(!modelIndex.isValid())
|
||
{
|
||
continue;
|
||
}
|
||
CAiAlarmTreeItem *item = static_cast<CAiAlarmTreeItem*>(modelIndex.internalPointer());
|
||
if(item->isAi())
|
||
{
|
||
AiAlarmMsgPtr ptr = NULL;
|
||
if(item->getAiPtr(ptr))
|
||
{
|
||
QList<AlarmMsgPtr> listPtr = item->getChildAlarmPtr();
|
||
for(int index(0);index<listPtr.size();index++)
|
||
{
|
||
if(listPtr.at(index)->m_tagname_type == E_TAGNAME_ANA || listPtr.at(index)->m_tagname_type == E_TAGNAME_ACC)
|
||
{
|
||
time_stamp = listPtr.at(index)->time_stamp;
|
||
trendMap[listPtr.at(index)->uuid_base64] = listPtr.at(index)->key_id_tag;
|
||
}
|
||
}
|
||
}
|
||
}else
|
||
{
|
||
AlarmMsgPtr ptr = NULL;
|
||
if(item->getPtr(ptr))
|
||
{
|
||
if(ptr->m_tagname_type == E_TAGNAME_ANA || ptr->m_tagname_type == E_TAGNAME_ACC)
|
||
{
|
||
time_stamp = ptr->time_stamp;
|
||
trendMap[ptr->uuid_base64] = ptr->key_id_tag;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(trendMap.size()<= 0)
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("请选中含有趋势的告警(模拟量和累积量)!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("请选中含有趋势的告警(模拟量和累积量)!"), QMessageBox::Ok);
|
||
return ;
|
||
}else
|
||
{
|
||
//发出打开趋势的信号
|
||
emit openTrend(time_stamp,trendMap.values());
|
||
//test(trendMap.values());
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::rightVideo0()
|
||
{
|
||
QModelIndex index = ui->alarmView->currentIndex();
|
||
if(!index.isValid())
|
||
{
|
||
return ;
|
||
}
|
||
QList<AlarmMsgPtr> listInfo = m_pModel->getListShowAlarmInfo();
|
||
AlarmMsgPtr info = listInfo.at(index.row());
|
||
if(info != NULL)
|
||
{
|
||
if(info->m_needVideoAlm)
|
||
{
|
||
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);
|
||
}else
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("请选中具有视频的告警!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("请选中具有视频的告警!"), QMessageBox::Ok);
|
||
return ;
|
||
}
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::rightVideo1()
|
||
{
|
||
if(!m_treeModel)
|
||
{
|
||
return;
|
||
}
|
||
QModelIndex index = ui->aiAlarmTreeView->currentIndex();
|
||
if(!index.isValid())
|
||
{
|
||
return ;
|
||
}
|
||
CAiAlarmTreeItem *item = static_cast<CAiAlarmTreeItem*>(index.internalPointer());
|
||
if(item->isAi())
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("请选中具有视频的告警!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("请选中具有视频的告警!"), QMessageBox::Ok);
|
||
return ;
|
||
}else
|
||
{
|
||
AlarmMsgPtr ptr = NULL;
|
||
if(item->getPtr(ptr))
|
||
{
|
||
if(ptr->m_needVideoAlm)
|
||
{
|
||
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);
|
||
}else
|
||
{
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("请选中具有视频的告警!"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("请选中具有视频的告警!"), QMessageBox::Ok);
|
||
return ;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::rightFaultRecord0()
|
||
{
|
||
QModelIndex index = ui->alarmView->currentIndex();
|
||
if(!index.isValid())
|
||
{
|
||
return ;
|
||
}
|
||
QList<AlarmMsgPtr> listInfo = m_pModel->getListShowAlarmInfo();
|
||
AlarmMsgPtr info = listInfo.at(index.row());
|
||
if(info != NULL)
|
||
{
|
||
//故障录播暂不实现
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("故障录播暂不实现"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("故障录播暂不实现"), QMessageBox::Ok);
|
||
return ;
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::rightFaultRecord1()
|
||
{
|
||
if(!m_treeModel)
|
||
{
|
||
return ;
|
||
}
|
||
QModelIndex index = ui->aiAlarmTreeView->currentIndex();
|
||
if(!index.isValid())
|
||
{
|
||
return ;
|
||
}
|
||
CAiAlarmTreeItem *item = static_cast<CAiAlarmTreeItem*>(index.internalPointer());
|
||
if(item->isAi())
|
||
{
|
||
AiAlarmMsgPtr ptr = NULL;
|
||
if(item->getAiPtr(ptr))
|
||
{
|
||
//故障录播暂时不实现
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("故障录播暂不实现"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("故障录播暂不实现"), QMessageBox::Ok);
|
||
return ;
|
||
}
|
||
}else
|
||
{
|
||
AlarmMsgPtr ptr = NULL;
|
||
if(item->getPtr(ptr))
|
||
{
|
||
//故障录播暂时不实现
|
||
// QMessageBox *msgBox = new QMessageBox(this);
|
||
// msgBox->setObjectName("msgbox");
|
||
// msgBox->setText(tr("故障录播暂不实现"));
|
||
// QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
// msgBox->setDefaultButton(skip);
|
||
// msgBox->exec();
|
||
QMessageBox::warning(this, tr("提示"), tr("故障录播暂不实现"), QMessageBox::Ok);
|
||
return ;
|
||
}
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::rightAccidentReview0()
|
||
{
|
||
QModelIndex index = ui->alarmView->currentIndex();
|
||
if(!index.isValid())
|
||
{
|
||
return ;
|
||
}
|
||
QList<AlarmMsgPtr> listInfo = m_pModel->getListShowAlarmInfo();
|
||
AlarmMsgPtr info = listInfo.at(index.row());
|
||
if(info != NULL)
|
||
{
|
||
if(!info->graph_name.isEmpty())
|
||
{
|
||
emit openAccidentReview(info->time_stamp-FAULT_RECORD_TIME,FAULT_RECORD_TIME*2,info->graph_name);
|
||
}
|
||
else
|
||
{
|
||
CAccidentReviewDialog *dialog = new CAccidentReviewDialog(m_strAccidenPath, this);
|
||
if(dialog->exec() == QDialog::Accepted)
|
||
{
|
||
emit openAccidentReview(info->time_stamp-FAULT_RECORD_TIME,FAULT_RECORD_TIME*2,dialog->getCurrentGraph());
|
||
}
|
||
delete dialog;
|
||
dialog = NULL;
|
||
}
|
||
}
|
||
}
|
||
|
||
void CAlarmForm::rightAccidentReview1()
|
||
{
|
||
if(!m_treeModel)
|
||
{
|
||
return ;
|
||
}
|
||
QModelIndex index = ui->aiAlarmTreeView->currentIndex();
|
||
if(!index.isValid())
|
||
{
|
||
return ;
|
||
}
|
||
CAiAlarmTreeItem *item = static_cast<CAiAlarmTreeItem*>(index.internalPointer());
|
||
if(item->isAi())
|
||
{
|
||
AiAlarmMsgPtr ptr = NULL;
|
||
if(item->getAiPtr(ptr))
|
||
{
|
||
CAccidentReviewDialog *dialog = new CAccidentReviewDialog(m_strAccidenPath, this);
|
||
if(dialog->exec() == QDialog::Accepted)
|
||
{
|
||
emit openAccidentReview(ptr->time_stamp-FAULT_RECORD_TIME,FAULT_RECORD_TIME*2,dialog->getCurrentGraph());
|
||
}
|
||
delete dialog;
|
||
dialog = NULL;
|
||
}
|
||
}else
|
||
{
|
||
AlarmMsgPtr ptr = NULL;
|
||
if(item->getPtr(ptr))
|
||
{
|
||
if(!ptr->graph_name.isEmpty())
|
||
{
|
||
emit openAccidentReview(ptr->time_stamp-FAULT_RECORD_TIME,FAULT_RECORD_TIME*2,ptr->graph_name);
|
||
}
|
||
else
|
||
{
|
||
CAccidentReviewDialog *dialog = new CAccidentReviewDialog(m_strAccidenPath, this);
|
||
if(dialog->exec() == QDialog::Accepted)
|
||
{
|
||
emit openAccidentReview(ptr->time_stamp-FAULT_RECORD_TIME,FAULT_RECORD_TIME*2,dialog->getCurrentGraph());
|
||
}
|
||
delete dialog;
|
||
dialog = NULL;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* @brief CAlarmForm::test 测试输出
|
||
* @param tagList
|
||
*/
|
||
void CAlarmForm::test(QStringList tagList)
|
||
{
|
||
QString tag = QString();
|
||
for(int index(0);index<tagList.size();index++)
|
||
{
|
||
tag +=tagList.at(index);
|
||
tag+=",";
|
||
}
|
||
QMessageBox *msgBox = new QMessageBox(this);
|
||
msgBox->setObjectName("msgbox");
|
||
msgBox->setText(tag);
|
||
QPushButton *skip = msgBox->addButton(tr("确定"), QMessageBox::ActionRole);
|
||
msgBox->setDefaultButton(skip);
|
||
msgBox->exec();
|
||
return ;
|
||
}
|
||
|
||
void CAlarmForm::inhibitAlm(const AlarmMsgPtr &alm)
|
||
{
|
||
iot_net::CMbMessage msg;
|
||
msg.setSubject(alm->sub_system, CH_HMI_TO_OPT_OPTCMD_DOWN);
|
||
SOptTagSet sOptTagSet;
|
||
SOptTagQueue optTagQueue;
|
||
|
||
if(createReqHead(sOptTagSet.stHead,alm)!= iotSuccess)
|
||
{
|
||
return ;
|
||
}
|
||
QString keyIdTag = alm->key_id_tag;
|
||
if(keyIdTag.endsWith(".value"))
|
||
{
|
||
keyIdTag.replace(QString(".value"),QString(".status"));
|
||
}else
|
||
{
|
||
return ;
|
||
}
|
||
|
||
optTagQueue.strKeyIdTag = keyIdTag.toStdString();
|
||
optTagQueue.nIsSet = 1;// 0:取消;1:设置;
|
||
optTagQueue.fSetValue = 1;
|
||
optTagQueue.strStateText = "";
|
||
optTagQueue.bIsPointQuery = false;
|
||
optTagQueue.nLocationId = alm->location_id;
|
||
optTagQueue.nSubSystem = alm->sub_system;
|
||
|
||
sOptTagSet.vecTagQueue.push_back(optTagQueue);
|
||
std::string content = COptTagSet::generate(sOptTagSet);
|
||
|
||
msg.setMsgType(MT_OPT_PINHIBIT_ALARM);
|
||
|
||
msg.setData(content);
|
||
LOGINFO("%s",QString::fromStdString(content).toStdString().c_str());
|
||
if(m_communicator == Q_NULLPTR)
|
||
{
|
||
QMessageBox::warning(this, tr("提示"), tr("禁止告警失败!"), QMessageBox::Ok);
|
||
}
|
||
if(!m_communicator->sendMsgToDomain(msg, alm->domain_id))
|
||
{
|
||
QMessageBox::warning(this, tr("提示"), tr("禁止告警失败!"), QMessageBox::Ok);
|
||
}
|
||
}
|
||
|
||
bool CAlarmForm::permCheck(int location, int region)
|
||
{
|
||
iot_service::CPermMngApiPtr permMngPtr = iot_service::getPermMngInstance("base");
|
||
if(permMngPtr != NULL)
|
||
{
|
||
permMngPtr->PermDllInit();
|
||
int nUserGrpId;
|
||
int nLevel;
|
||
int nLoginSec;
|
||
std::string strInstanceName;
|
||
int userId;
|
||
if(PERM_NORMAL != permMngPtr->CurUser(userId, nUserGrpId, nLevel, nLoginSec, strInstanceName))
|
||
{
|
||
userId = -1;
|
||
return false;
|
||
}
|
||
std::vector <int> vecRegionOptId;
|
||
QList<int> regList;
|
||
QList<int> locList;
|
||
std::vector <int> vecLocationOptId;
|
||
if(PERM_NORMAL == permMngPtr->GetSpeFunc(OPT_FUNC_SPE_OPT_OVERRIDE, vecRegionOptId, vecLocationOptId))
|
||
{
|
||
|
||
std::vector <int>::iterator region = vecRegionOptId.begin();
|
||
while (region != vecRegionOptId.end())
|
||
{
|
||
regList.append(*region++);
|
||
}
|
||
|
||
std::vector <int>::iterator location = vecLocationOptId.begin();
|
||
while (location != vecLocationOptId.end())
|
||
{
|
||
locList.append(*location++);
|
||
}
|
||
}
|
||
if(locList.contains(location) && regList.contains(region))
|
||
{
|
||
return true;
|
||
}else
|
||
{
|
||
QMessageBox::warning(this, tr("警告"), tr("无禁止告警权限!"), QMessageBox::Ok);
|
||
return false;
|
||
}
|
||
}
|
||
QMessageBox::warning(this, tr("警告"), tr("初始化权限失败!"), QMessageBox::Ok);
|
||
return false;
|
||
}
|
||
|
||
int CAlarmForm::createReqHead(SOptReqHead &head, const AlarmMsgPtr &alm)
|
||
{
|
||
if(!m_ptrSysInfo)
|
||
{
|
||
if(!createSysInfoInstance(m_ptrSysInfo))
|
||
{
|
||
LOGERROR("创建系统信息访问库实例失败!");
|
||
return iotFailed;
|
||
}
|
||
}
|
||
|
||
int userID = -1;
|
||
int usergID = -1;
|
||
int level;
|
||
int loginSec;
|
||
std::string instanceName;
|
||
|
||
iot_service::CPermMngApiPtr permMng = iot_service::getPermMngInstance("base");
|
||
if(permMng != NULL)
|
||
{
|
||
if(permMng->PermDllInit() != PERM_NORMAL)
|
||
{
|
||
LOGERROR("权限接口初始化失败!");
|
||
return iotFailed;
|
||
}else
|
||
{
|
||
if(PERM_NORMAL != permMng->CurUser(userID, usergID, level, loginSec, instanceName))
|
||
{
|
||
userID = -1;
|
||
return iotFailed;
|
||
}
|
||
}
|
||
}
|
||
head.strSrcTag = "alarm_window";
|
||
head.nSrcDomainID = m_nDomainId;
|
||
head.nDstDomainID = alm->domain_id;
|
||
|
||
if(m_ptrSysInfo != Q_NULLPTR)
|
||
{
|
||
iot_public::SAppInfo stAppInfo;
|
||
m_ptrSysInfo->getAppInfoBySubsystemId(alm->sub_system,stAppInfo);
|
||
head.nAppID = stAppInfo.nId;
|
||
}else
|
||
{
|
||
head.nAppID = alm->sub_system;
|
||
}
|
||
head.strHostName = m_nodeName;
|
||
head.strInstName = instanceName;
|
||
head.strCommName = m_communicator->getName();
|
||
head.nUserID = userID;
|
||
head.nUserGroupID = usergID;
|
||
head.nOptTime = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||
|
||
return iotSuccess;
|
||
}
|
||
|
||
void CAlarmForm::reloadDevTree()
|
||
{
|
||
updateAlarmOperatePerm();
|
||
loadDeviceGroupFilterWidget();
|
||
}
|